Blogs

Deeson: Can Drupal events learn from WordCamp London?

Drupal Planet - 8 hours 45 min ago

Over the past couple of years I’ve attended quite a few conferences like DrupalCon Amsterdam & Barcelona, DrupalCamp Vienna, European Drupal Days, Drupal Developer Days and SymfonyCon Berlin.

Last weekend I had the opportunity to attend and speak at my first WordCamp. My friend Jam and I spoke about Challenges and Solutions in Getting your Open Source Company to Contribute which we have done many times before.

My colleague Ronald Ashri was also speaking about An AI Bot will Build and Run your Next Site… Eventually, sharing some of our work on chatbots and applied artificial intelligence

We do this because we firmly believe that organisations can achieve far greater success if they work together and improve the world while they do so. As with other conferences I was greeted by a warm and welcoming community. The fact that I’m from the Drupal community didn’t bother anyone and it was relatively easy to find common grounds with everyone I met. So far no surprises, because we all shared a love for open source technology.

That said, I did find that this conference and the people that attended vastly different than what I experienced at any other tech conference to date. The main difference being their focus on diversity, accessibility, inclusivity and user experience. As it turns out, not only WordPress is extremely user focussed and easy to use, so are its conferences. They have gone out of their way to make the conference as inclusive and accessible to everyone. To list a few of the things that stood out for me:

  • Creche - You’ve got kids? WordCamp has you sorted. For a mere £5 per child per day your kids are close and taken care off while you attend your favourite sessions. This lowers the bar for people with young children that otherwise maybe wouldn’t be able to attend.
  • Life essentials boxes - napkins, sanitary pads, tampons, you name it they’ve made sure they’ve got it. Not just in the female facilities, but in the male facilities as well. An awesome gesture of acceptance and inclusivity for transgender attendees.
  • Speech To Text Reporters - Each room had two Speech To Text Reporters that provided live session transcription. One transcribed the current session, while the other corrected any errors in the previous transcription so that it can be used with the session footage that will be posted on the internet.
 

A post shared by Jeffrey A. "jam" McGuire (@horncologne) on Mar 18, 2017 at 2:33am PDT

But the differences were not limited to the organisation only. The attendees and sessions seemed different as well. Most conferences I’ve attended were mostly visited by developers and most sessions would be about “How to do something awesome with framework A”, “What changed between version X and Y” or “How your application can communicate with API Z”.

The technical sessions didn’t offer me many new insights, but reaffirmed that all software communities face (and solve) the same problems and challenges and the non-technical sessions reminded me that as developers we have a responsibility to our users. The responsibility to ensure that they can access the information our products provide and that no-one is excluded from being able to access that information. All in all WordCamp was highly similar, but also very different.

Yes it’s still attended by developers, but they are not necessarily the majority. I’ve spoken with designers, business owners, entrepreneurs, user experience designers and project managers and heard a lot less technical talk while walking around the venue. The focus seems to be more about “I’ve got a business and want to find out how WordPress can help me make the most of it” than “I’ve always used WordPress and now want to know how to apply it to this new project”.

Looking back at the other conferences I’ve attended I think a lot can be learned from the WordPress community. The session diversity, clear communication and open atmosphere encourage a wide range of attendees, which in turn allows people with entirely different roles to talk to each other and gain a better understanding of each other’s (business) needs and be inspired by their ideas.

WordCamp London turned out to be all that’s good about tech conferences. I like it, sign me up for more!

We’re hiring in Europe at the moment - find out more about working at Deeson.

Categories: Blogs

Nuvole: Our presentations at Drupal Dev Days Seville

Drupal Planet - 9 hours 8 min ago
New directions for Config Split and UI Patterns

Last week we attended and sponsored the Drupal Developer Days in Seville where we also had two well attended sessions. Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8 and Advanced Configuration Management with Config Split et al. attached here are the promised slides, as well as a few updates about the modules.

What's new in Config Split Drush

As we posted about before, drush supports the Config Split workflow since 8.1.10. In the next version drush will drop the support for its --skip-modules flag and people using it should upgrade to using Config Split.

Split Storage in Database

Previous versions of Config Split allowed to set an empty split folder which resulted in the configuration to be lost. To avoid saving the configuration into files under version control one would therefore have to set up a temporary directory and save the split there. But with the last development release a separate database storage is used when not specifying a split folder. This allows configuration to be "stashed" in the database for a deployment. A specific export first is still and will always be necessary by design.

What's new in UI Patterns

Following a productive BOF meeting at DDD, it was decided to move everything that concerns defining and displaying patterns locally into a separate module.

This will allow for a better and more solid architecture: the main UI Patterns module will be solely responsible to provide plugins and other glue code: it will then be responsibility of modules implementing component library integrations to expose their components using pattern derivers.

Discussion is ongoing at https://github.com/nuvoleweb/ui_patterns/issues/86 and more generic future plans are being dicussed at https://github.com/nuvoleweb/ui_patterns/issues/76

Tags: Drupal 8Drupal PlanetAttachments:  Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8 Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Categories: Blogs

OhTheHugeManatee: Stay for Community

Drupal Planet - 14 hours 12 min ago

The Crellpocalypse in the Drupal world last week has shaken the entire community. This event and its handling have called our fundamental values and structures into question. We’ve had fights on social media, calls for Dries to step down, and valuable contributors stepping away from the community. I have friends on every side of the situation, but all I can think is: This seems like the perfect time for a singing, dancing, spandexed pageant about the Drupal community.

Why? For those who don’t know, I’m one of the authors of the DrupalCon Prenote, the “pre-keynote” show that kicks off DrupalCon right before Dries’ keynote. The organizer (and my officemate), Jeffrey A. “jam” McGuire and I have been living our own special version of the crisis (Read Jam’s post about taking sides on this here). Our friend Larry Garfield has been an enthusiastic part of the Prenote ever since his first appearance as “Lord Over-Engineering” at Drupalcon Austin. Dries has often played a special guest role, too. With Drupalcon Baltimore looming on the horizon, everything seems to be coming together in one awful moment full of painful reminders – and it’s just when we’re supposed to be cheering for “community.” That awful conjunction is what makes this next Prenote in Baltimore more important than ever.

I have a tremendous respect for how painful this whole situation is for everyone involved. This very public meltdown, which has already done tremendous material damage, is made even more painful by the personal friendships of the key people involved. Klaus, Dries, and Larry have been colleagues for more than a decade. Even if this was only a private falling out, it would have been a painful one. And this is a public explosion. I can’t imagine the emotional strain that each of them is under right now. Internet mob outrage is a terrible experience, made much worse when it comes from your friends and colleagues, directed at your friends and colleagues.

And this is exactly why we need a Prenote right now. Because this is terrible shit that we’re wading through, and the Prenote exists to remind us of why we should keep going. The Drupal community – not the specific leadership, but the agglomeration of people, practices, code, and rules – has a lot that’s worth fighting for. We are the largest open source software community in the world, with a uniquely personal connection to its members. An incredible diversity of contributors from every culture imaginable who, for the most part, manage to work very well together.

The Drupal community is on the leading edge of how a community of this size and diversity can work. No one has ever done this before. Things like our Code of Conduct, Community Working Group, and conflict resolution process, can seem like established and unassailable systems. They aren’t. Go read the version history of those links; we just get a group of people together at a Drupalcon or on video conference to try to figure out how to handle this stuff, and then codify it in writing. We take models from other kinds of communities and try to adapt them, we suggest crazy new ideas and directions. As a community, Drupal actively and aggressively tries to figure out how to make itself more diverse, and less conflict prone. Humanity has never done collaborative communities on this scale before, and the Drupal Community is on the bleeding edge of it all.

The cost of the bleeding edge is that we make mistakes. We set off conflicts, we discover new kinds of obstacles. We muddle through every time, and then in retrospect try to find a better way forward for next time. I don’t mean to diminish the size or importance of any of these conflicts. They can be serious, existential crises.

  • When Acquia first formed and started to hold outsize influence, it was an existential crisis. We had to figure out how to handle a conflict of interest in our leadership, and what to do about a (then) totally asymmetrical services market. Acquia is now just one large player of several in the Drupal marketplace, and Dries found a compromise between his interests that has lasted almost a decade.
  • When Nate and Jenn forked Drupal into Backdrop CMS, it presented another existential crisis for our community. We had never had such a credible fork from such key community members before. It was the apex of a crisis in the development direction for the whole project. We had to figure out how to address developer experience, how to work with a forked project, and even how to continue working with the forkers themselves. Backdrop is now a normal part of the ecosystem; Jenn and Nate remain important and welcomed Drupal community leaders almost four years later.
  • We have had critical tensions, messy relationships, and fallings out with some of our most appreciated developers and community leaders. Whether it’s offense taken at Morten, or outbursts from Chx, these have divided our community and forced us to solve diversity problems that no one else has ever had to deal with.

I could go on. The point is: With each crucible, we the Drupal community must try to learn and build better systems for the next time.

So right now, in the midst of all this anger, this prejudice, and these accusations, I’m here to say: we will learn from this, too. The Drupal community is extraordinary, but we must adapt in order to survive. Losing Larry is a big hit to our community in almost every dimension. This public explosion has been a big hit to us in almost every other dimension. The arguments and animosities we’ve unleashed feel like they will tear us apart. But we must look forward. We must use this event for introspection and carry on as a better, improved community.

Do you think Larry was punished for thoughtcrime? Pitch in and help build a system where the next Larry can’t be treated that way. Do you think Dries and the DA deserve our trust in their decision? Join up and help make sure the next iteration preserves the strength of independent leadership.

The prenote is about why we are here, why we’ve stayed here all these years. Because it’s fun, because it’s supportive, because we love it. Sometimes the best way to start addressing your pain is through humor – and we desperately need to start addressing this.

However you feel about the Crellpocalypse, please don’t leave. Not yet. Stay, and help the community improve. Don’t stay for your job. Don’t stay for Dries, or the DA, or Larry. Stay for the community.

I’ll see you at the Prenote.

Categories: Blogs

Agiledrop.com Blog: AGILEDROP: Drupal Logos in Human Professions

Drupal Planet - 16 hours 53 min ago
Druplicons in Human Professions were promised a long time ago. At the very beginning of our »Druplicon marathon« to be precise. We postponed them, for some time, but after Humans and Superhumans, Fruits and Vegetables, Animals, Outdoor activities, National Identities and Emotions, it's their turn to shine. So, here are Drupal Logos in Human Professions. Druplicon as a Miner (DrupalCamp Donetsk 2014)     Druplicon as a Spaceman     Druplicon as a Sailor (DrupalCamp Schwerin 2017)     Druplicon as a Professor     Druplicon as an Engineer     Druplicon as a Conductor     Druplicon… READ MORE
Categories: Blogs

Jeff Geerling's Blog: Drupal VM on Windows - a fast container for BLT project development

Drupal Planet - March 29, 2017 - 7:57pm
AKA "Supercharged Windows-based Drupal development"

tl;dr: Use a Samba share in the VM mounted on the host instead of using a Vagrant synced folder, and use Drupal VM 4.4's new drupal_deploy features. See the video embedded below for all the details!

*/

I've often mentioned that Windows users who want to build modern Drupal sites and apps are going to have a bit of a difficult time, and even wrote a long post about why this is the case (Developing with VirtualBox and Vagrant on Windows).

Categories: Blogs

Evolving Web: Why is the Drupal Bootstrap Theme So Successful

Drupal Planet - March 29, 2017 - 3:50pm

As a Drupal themer, it's rare that I choose something other than the Bootstrap base theme for a new project. Besides its quality and popularity, there are some specific technical reasons why Bootstrap is such an attractive option.

The internet loves Bootstrap

According to BuiltWith.com, as of March 2017, almost 12 million websites use the Bootstrap library. And w3techs says it's used by 14.9% of all public internet sites. For sure that is a lot.

This makes Bootstrap the top JS Framework worldwide and the second most popular JS library ever used, right after jQuery, which is used across 72% of the web. This means that there are a lot of docs and examples out there to use as a guide.

Thousands of developers know Bootstrap and work with it every day. And because Bootstrap is not Drupal-specific, you can use Bootstrap for your Drupal theme and your other non-Drupal projects. Front-end developers who know Bootstrap can be more easily on-boarded on your project if you go with Bootstrap as a base theme.

A Bootstrap theme doesn't have to look like Bootstrap

If you start with Bootstrap and don't customize the styling of your theme, of course, you will end up with that classic Bootstrap look and feel. But the magic of Bootstrap isn't just about how it looks. It is also how it behaves and the way it provides us a solid framework of interactions and components that we can easily customize to the most precise design specs.

Parts of Bootstrap like the grid, breakpoints, messaging and modals are generic components that you can reuse and restyle for your projects pretty easily. As a themer, you can either change these using the Advanced Theme Settings or do these custom on your project.

Advanced Theme Settings 

Since Drupal 7, when Bootstrap theme was created with a lot of settings that allow site builders to customize it out of the box and without coding. This is a very common practice across most Drupal themes, but on this specific case, you can "tweak" Bootstrap library specific components that integrate with your Drupal site like the Navbar, Breadcrumbs, Modals and so on.

Even if you are not an experienced Drupal Themer, you can jump into the Settings and start moving things around while customizing your website's appearance and behavior.

Another great feature is that you can set to use Bootstrap library from a CDN, change the library version you want to support and even use different "skins" from Bootswatch.com.

For a complete list of the theme specific settings, refer to the Bootstrap Theme Settings Docs.

Your theming style matters

In 2016, among many other projects, we developed a couple of Drupal 8 corporate websites on top of Bootstrap theme for the Council for Responsible Nutrition and CARTaGene. On both projects, designers were free enough to come up with their concepts without knowing we were going to use that specific framework to make these come to life and get launched.

By the way, did I mention that this site you see right now, is also Drupal 8 + Bootstrap Theme based?

Drupal loves Bootstrap

In a previous blog post, I talked about "Drupal Theming and Site Building: 6 Best Practices' and listed a set of criteria to use when considering a base theme for your Drupal projectSo here's how the Bootstrap theme measures up against these criteria:

  • How many people use it? The Bootstrap theme had more than 140,000 Drupal 7 & 8 reported installs as of March 2017. That is more than 10% of Drupal sites out there and is the most-installed theme for Drupal 8 so far.
  • Is it increasing? Over time, more and more front-end developers are adopting Bootstrap, according to the installation statistics from Drupal.org.
  • Is it being maintained? Bootstrap theme is actively maintained. Just check the issue queue.
  • How do I get started? Well, the documentation is extensive and detailed. There is even a specific website for it at http://drupal-bootstrap.org.
  • How secure is it? Stable releases are covered by the security advisory policy.

In Drupal 8, there are templates files for almost every HTML component printed on the page, so you can easily customize the way that Bootstrap classes are applied. This makes it really easy to use the library the way you want. You're not stuck with the decisions made by the base theme developers.

The Amazing People Behind Bootstrap

Last but not least, Open Source does it again:

Bootstrap Library Github repo is mainly managed by @mdo and @fat plus an active community of contributors. The library started in 2011 and since then it's been constantly increasing with more and more contributions every day.

For the Drupal base theme there is also a long list of contributors, but I'll give a special mention to Mark Carver, who takes care of leading the project development as the main maintainer and does an amazing work while carefully mixing these two technologies in the best way possible.

If you jump into the issue queue, you will notice that, just because a patch works, doesn't mean it will go into a base theme used by +140,000 websites as an update before being carefully reviewed and tested by the community. Thanks a lot to Mark and everyone else behind the theme.

How to Get Started?

If you are new to Drupal:

If you have some Drupal theming experience I suggest you read about:

And if you are an advanced Drupal Themer, we would love to have you contributing back:

+ more awesome articles by Evolving Web
Categories: Blogs

Acquia Developer Center Blog: 10 Ways to Build Quality into Agile Drupal Development

Drupal Planet - March 29, 2017 - 1:19pm

How to move fast, be flexible, and maintain high quality while building a digital experience.

Tags: acquia drupal planet
Categories: Blogs

Annertech: Allowing Editors to Choose the Image Style in Drupal 8 Image Fields

Drupal Planet - March 29, 2017 - 11:02am
Allowing Editors to Choose the Image Style in Drupal 8 Image Fields

While building a site recently, we had a requirement for teaser images to be in a landscape or portrait orientation. We could have created two image fields and told the client to just fill in one - but that would mean editors would be responsible for cropping the image which would add extra effort to their work. Instead what we did was used one image field and one select list to choose if they image should be 'landscape' or 'portrait' in teasers.

Categories: Blogs

ADCI Solutions: Product development process

Drupal Planet - March 29, 2017 - 7:27am

Alike any team that focuses on full cycle Drupal development we work with rather complex projects. Usually we go through all the stages: from idea to launch. We love having control over the process, that's why we created the simple yet working scheme. Following its steps gives us confidence that nothing is missed. This article describes the workflow of one of the ADCI Solutions projects and emphasize a designer's role at each stage. Try this scheme out and learn other tips that we included in the article.

Click here to get started

Categories: Blogs

Colorfield: Development best practices learned from the Drupal Dev Days Seville 2017

Drupal Planet - March 29, 2017 - 3:50am
Development best practices learned from the Drupal Dev Days Seville 2017 christophe Wed, 29/03/2017 - 08:50
Categories: Blogs

James Oakley: hook_uninstall not running? Drupal schoolboy errors #1

Drupal Planet - March 28, 2017 - 1:04pm

I'll put this here, in case it helps anyone else.

I'm owning up to Drupal Schoolboy Error #1.

I was writing a very simple module. It did so little, that I wanted to keep things as simple as possible — just a .info file, and a .module file.

Blog Category: Drupal Planet
Categories: Blogs

myDropWizard.com: Most common Drupal site building pitfalls and how to avoid them! (Part 3 of 3)

Drupal Planet - March 28, 2017 - 11:58am

This is the third in a series of articles, in which I'd like to share the most common pitfalls we've seen, so that you can avoid making the same mistakes when building your sites!

myDropWizard offers support and maintenance for Drupal sites that we didn't build initially. We've learned the hard way which site building mistakes have the greatest potential for creating issues later.

And we've seen a lot of sites! Besides our clients, we also do a FREE in-depth site audit as the first step when talking to a potential client, so we've seen loads of additional sites that didn't become customers.

In the first article, we looked at security updates, badly installed module code and challenges ith "patching" modules and themes, as well as specific strategies for addressing each of those problems. In the second article, we looked at how to do the most common Drupal customizations without patching.

In this article, we're going to look at some common misconfigurations that make a site less secure, and how to avoid them!

NOTE: even though they might take a slightly different form depending on the version, most of these same pitfalls apply equally to Drupal 6, 7 and 8! It turns out that bad practices are quite compatible with multiple Drupal versions ;-)

Categories: Blogs

MidCamp - Midwest Drupal Camp: Free Community Drupal Training at MidCamp 2017

Drupal Planet - March 28, 2017 - 10:38am

It started as a question.  Why do Drupal camps only have trainings on a separate day?  The legitimate answer was that trainings and sessions should not compete for audiences for a normal Drupal camp audience.  But what if the trainings were not for that normal Drupal camp audience?

When all of the hard work was done by the MidCamp venue team to secure the DePaul University Student Center for MidCamp 2017, we immediately started exploring the idea of having half day Drupal training sessions for those that would nornally not attend a Drupal camp.  We reserved two extra rooms for this idea.

While I looked for interested parties who would be interested in attending the trainings, Joseph Purcell of Digital Bridge Solutions worked to organize an Introduction to Making Websites with Drupal itinerary and found great trainers to lead the event: Michael Chase, ‎Instructor at DePaul University College of Computing and Digital Media, and Aaron Meeuwsen, Web Developer at HS2 Solutions, along with several other volunteers, Scott Weston and Matt Ramir from HS2, and Doug Dobrzynski from PMMI Media Group.  Without them, we couldn't have made this happen. I would also like to thank my employer, Xeno Media for contributing some of my time to help organize these trainings.

We've reached out to, and are happy to be working with such great local Chicago technology groups.  Girl Develop It, which provides programs for adult women interested in learning web and software development in a judgment-free environment, the IT Knowledge and Abilities Network (ITKAN), which provides professional networking and growth organization with a focus on professionals and aspiring professionals with disabilities, and Women Who Code, a global non-profit dedicated to inspiring women to excel in technology careers all answered our call.

But we still have room for more.  Do you know of someone who would benefit from free Intro to Drupal Training?  We want you to invite them!

The trainings will cover basic CMS tasks like editing and publishing content, creating navigation menus, and placement of content on the site, and will approach into more complex tasks such as module installation and site configurations. Additionally, we’ll show the various ways the Drupal community can help through the issue queue, meetups, job boards, and mentorship.

The sessions are:

  • Friday March 31st - 9:00 am - 12:00 pm
  • Friday March 31st - 1:00 pm - 4:00 pm
  • Saturday April 1st - 9:00 am - 12:00 pm
  • Saturday April 1st - 1:00 pm - 4:00 pm

Get your free ticket today!

Don't be shy, please share and and invite anyone you think would benefit from these trainings.  Ticket enrollment is open, and we would love to have every seat filled!

Categories: Blogs

Chromatic: Configuring Redis Caching with Drupal 8

Drupal Planet - March 28, 2017 - 10:20am

How to install and configure Redis caching for Drupal 8.

Categories: Blogs

Darren Mothersele: How to do Everything with PHP Middleware (DrupalCamp London)

Drupal Planet - March 28, 2017 - 6:30am

At the DrupalCamp in London earlier this month I gave a talk about PHP Middleware. You can see a recording of the talk on YouTube. Here’s a summary, in case you don’t want to watch the whole talk, or the distorted audio upsets you, or if you want the links and references:

Simple vs Easy

I started with a reference to the important talk by Rich Hickey, Simple Made Easy. This is high up on my list of videos every software developer needs to watch. I began here because I think it’s important to identify the difference between simple and easy, to identify where complexity sneaks into our systems. I have found PHP Middleware to be an important tool in the fight against complexity.

“programming, when stripped of all its circumstantial irrelevancies, boils down to no more and no less than very effective thinking so as to avoid unmastered complexity, to very vigorous separation of your many different concerns.

Edsgar W. Dijkstra (1930 - 2002)

De-complecting PHP

I talked a bit about different ways to simplify development with PHP. Including: Domain-driven design, Hexagonal architecture (Ports and Adapters), Framework-independent code, Thin APIs, etc… In particular, I wanted to emphasise the importance of framework-independent code and the benefit of using common interfaces such as the ones developed as PSRs by PHP-FIG.

There was some discussion after about introducing unecessary abstractions, but I think this misses the point. Of course there is a trade off, but the key is to focus on the simplicity, on untwisting things (c.f. Rich Hickey).

De-coupled

Inspired by the Zend Expressive installation procedure, I imagined what Drupal 10 might look like, with fully-decoupled components.

Interfaces

The widespread adoption of PSR7 by the PHP community has lead to the popularity of PHP Middleware-based systems.

Why PSR7 when Symfony HTTP components were so popular? Well, that is an implementation - and rather than standardise on implementation, we should standardise against interfaces.

This allows more interoperability. I showed this pseudocode:

// Take the incoming request from Diactoros $request = ServerRequestFactory::fromGlobals(); $client = new Client(); // Response comes back from Guzzle $response = $client->send($request->withUrl($dest)); $body = simplexml_load_string( $response->getBody()->getContents()); // pass back to Diactoros (new SapiEmitter)->emit($response->withBody($body));

The example uses HTTP requests from Zend Diactoros, forwards them using the Guzzle HTTP client, and returns the response object from Guzzle using the SAPI Emitter from Diactoros.

This demonstrates the power of sharing standard interfaces. Here two packages are used together, both provide an implementation of PSR7 HTTP messages, and they work seamlessly because they both conform to the same interface, despite the differing implementation details.

Decorating Web Apps

This is what a typical web app looks like:

Which can be simplified to this:

A web app takes a request and returns a response.

The concept behind PHP Middleware is that you can decorate the app, to add new functionality, by intercepting the request on the way in, and the response on the way out. This avoids the complexity of intertwining your code throughout the ball of mud.

Here’s an example (pseudocode) for adding CORS functionality to an existing app:

$cors = analyze($request); switch ($cors->getRequestType()) { Case ERR_NO_HOST_HEADER: Case ERR_ORIGIN_NOT_ALLOWED: Case ERR_METHOD_NOT_SUPPORTED: Case ERR_HEADERS_NOT_SUPPORTED: Return createResponse(403); Case TYPE_REQUEST_OUT_OF_CORS_SCOPE: return $APP->process($request); Case TYPE_PRE_FLIGHT_REQUEST: $response = Utils\Factory::createResponse(200); Return $response->withHeaders($cors->getHeaders); default: $response = $APP->process($request); Return $response->withHeaders($cors->getHeaders); }

StackPHP first popularised the concept of middleware in PHP. This diagram is from their website:

There are other popular micro-frameworks based on this concept, such as Slim.

The core of your app is just a thin layer of business logic. Just your domain specific code. The rest can be wrapped in layers which isolate and separate concerns nicely.

Single-pass vs Double-pass

The double pass approach became the most popularly used signature for HTTP middleware, based on Express middleware from the JS community.

It looks like this:

// DOUBLE PASS function __invoke($request, $response, $next) { }

The request and the response are both passed into the middleware, along with a $next delegate that is called to pass control and carry on processing down the chain of middleware.

This double-pass approach is much newer, but used by most of the early adopters of PSR-7.

A single pass approach, looks like this:

// SINGLE PASS / LAMBDA function process($request, $delegate) { }

The issue is with how the response object is dealt with. In the double-pass approach, both are provided. The argument is that this is better for dependency inversion. Using the single pass approach you either need to hard code a dependency on a HTTP message implementation into your middleware when the response is required, or you need to inject a factory for generating the response.

PSR-15 HTTP Middleware

After the success of PSR7, with it’s wide adoption leading to much standardisation and interoperability in PHP frameworks, the next step is to standardise the middleware interface.

This is not yet an accepted PSR. At the time of writing it is still in draft status. It is available for use in the http-interop/http-middleware repo.

Invoker

As an aside, I mentioned the Invoker Interface. As per the docs:

“Who doesn’t need an over-engineered call_user_func()?”

In particular this library really simplifies the process of calling things and injecting dependencies. It also allows to call things using named parameters. I make extensive use of this, and I find making calls with named parameters makes code much easier to understand.

PSR-15 Interfaces

PSR-15 has two interfaces. Both define a method called process. One is the signature that middleware must support, which takes a PSR7 request and a PSR15 delegate. The other interface defines the process method for the delegate. The method on both interfaces is defined as returning a PSR7 response.

So you can compose a chain of middleware, pass in a request and get a response. The request is passed down the chain of middleware until a response is generated which is then passed back up the chain, possibly being decorated along the way.

For want of a better name, I refer to this chain of middleware as a stack. And, I have created a simple Stack Runner to handle the processing of a stack of PSR-15 middleware.

class StackRunner implements DelegateInterface { public function __construct( array $stack, InvokerInterface $invoker, ResponseFactoryInterface $responseFactory ) { ... } public function process(ServerRequestInterface $request) { if (!isset($this->stack[$this->current])) { return $this->responseFactory->createResponse(); } $middleware = $this->stack[$this->current]; $this->current++; return $this->invoker->call([$middleware, 'process'], [ 'request' => $request, 'delegate' => $this, ]); } } ADR (Action Domain Responder)

I went on to talk about ADR as being an adaptation of MVC that is more suitable for use in Web Apps. I’ve found this particularly useful when using Domain-Driven Design, or when used to create thin APIs where you have just a thin layer of business logic on top of a data store.

The issue with MVC is that the template is not the view. The “view” of a web app is the HTTP response, and we split this across our layers, as the body of the response is typically generated by the view, with the knowledge of HTTP being encoded into our controllers. We also bundle together various actions into one controller, which means instantiating the whole thing when we want to run one of the actions.

ADR offers an alternative separation of concerns, where the action methods of the controller are their own separate classes (or in my case anything invokable via the InvokerInterface). I use an InputHandler to deal with parsing the input from the HTTP Request, which the Invoker can then use (via the magic of named arguments).

The domain (Model in MVC terminology) is where the business logic lives. This is called domain, rather than model, to suggest use of domain-driven design.

To use ADR with PHP Middleware, add a resolver to the end of the chain of middleware to dispatch the request to the appropriate Action.

Action

I’ve created a reference implementation of an invokable Action.

Demo!

At this point in my talk I planned to give a demo of how you compose ADR with Middleware to create a working API. Unfortunately, I had some tech issues getting my computer linked up to the projector, and I was starting to feel really ill (full of cold). By this time the caffeine was starting to wear off, and I needed the talk to end!

I’ve put the example code up in a GitHub repo.

References
  • Simple Made Easy - talk by Rich Hickey
  • HTTP Middleware and HTTP Factory interfaces.
  • PSR15 Middlewares a set of really useful middlewares that can be used with a PSR15 middleware dispatcher.
  • Stack Runner my reference implementation of a very simple stack runner for executing a chain of PSR15 middleware.
  • Wafer an experimental implementation of the ADR idea to be used along with PSR15 middleware and the stack runner.

Drop me a line with any feedback. Thanks!

Categories: Blogs

Agiledrop.com Blog: AGILEDROP: Responsive Images in Drupal 8

Drupal Planet - March 28, 2017 - 5:56am
The days of fixed-width websites are long behind us, and with fluid widths came fluid images. In many cases, we don’t want to display the same image size on a mobile and on a desktop, because we truly don't need a 2000px wide image on a 480px device. Or we want to display a completely different image at some breakpoint. For this we have a HTML5 element which can contain a multiple elements with srcset and media attributes. The browsers choose the right source based on a media query. In my case, I had to show completely different image sizes on mobile vs.… READ MORE
Categories: Blogs

Janez Urevc: Time to take some time off the Drupal community

Drupal Planet - March 28, 2017 - 5:11am
Time to take some time off the Drupal community slashrsm Tue, 28.03.2017 - 10:11

When I joined the Drupal community I felt that I arrived in the enthusiastic, welcoming and positive environment. I felt that all contributions are appreciated and that we're all following more or less the same goal. This belief was also mostly the source of motivation for my extensive contributions to the Drupal 8 Media initiative in the past 4 years or so. This has dramatically changed in the last year or so and seems to be getting worse all the time.

Our community has governance and conflict-resolution rules. Everything should be clear and transparent. At least in theory. But in practice things don't work that way. Decisions (political and technical) are often made behind closed doors where only small fraction of the community is allowed to participate. Decision processes are nontransparent and leadership doesn't seem to feel any need to improve that. This was also the main reason why I recently decided to discontinue my DA membership.

I think that, in order to survive in the long term, we'll need to reform our community to become truly transparent and democratic. We've been "living" in a dictatorship and it has been working for us so far. But history shows that too much concentration of power in an small ruling clique almost always leads to its abuse (I strongly recommend this book).

My impression is that the community in general is getting increasingly toxic. It feels that there is more and more hypocrisy, lies, secret goals and partial interests being involved (and I think that the lack of transparency contributes to that). Best indicator for in my case are the community events which have (with some rare bright exceptions) become a burden instead of enjoyment for me. I still enjoy meeting some people that have become my friends during the years, but I recently started seeing the community in general as increasingly negative, abusing and exhausting.

Stress and bad mood directly linked to the happenings in the Drupal started affecting my personal life, including relations with my family. This is not acceptable and I decided to take some time off to think about the situation and to decide if and to what extent I want to remain active in the community. This decision was not made solely due to the most recent ousting (which also clearly showed how the community and its leadership actually work). It is based on many events that happened in last year or so.

This is my personal decision and has nothing to do with my employer. I really enjoy working at MD Systems and have no intentions to introduce any changes into that part of my life.

Categories: Blogs

Kalamuna Blog: Converting Drupal 7 Media Tags During a Drupal 8 Migration

Drupal Planet - March 28, 2017 - 12:37am
Converting Drupal 7 Media Tags During a Drupal 8 Migration John Ouellet Mon, 03/27/2017 - 20:37

As developers of all skill levels begin to migrate from old versions of Drupal to Drupal 8, it is always good to have references for some of the more arduous tasks out there.  Many of our clients for whom we built Drupal 7 sites used the media module and the awesomeness that it gave to their sites. Now, as I migrate some of these same sites to Drupal 8, I hit a bump in the road. The Drupal 7 Media tag can’t be rendered in the Drupal 8 site I am migrating to. This is because that functionality is not present in the Drupal 8 site.

Categories Articles Drupal Guidance
Categories: Blogs

MidCamp - Midwest Drupal Camp: Two days before before MidCamp

Drupal Planet - March 28, 2017 - 12:19am

Two days before before MidCamp, when all round the rug, not a creature was stirring, not even a bug.

Though the house was so empty, and missing it's stir, our Volunteer coordinator was out saying burrr (don't leave me out in the cold). Our Sprint lead was looking for sprinters to sprint, and our Trainers were looking for trainees to imprint!

MidCamp 2017 has 45 sessions for you to attend on Friday and Saturday, 4 Full day trainings on Thursday, and 4 Free half day trainings for you to invite anyone new to Drupal to attend.

In addition, we have socials for you to attend on Friday and Saturday, and a Sunday contrib Sprint to give back to Drupal.

It's spring in Chicago, and we hope you can join us!

Get your tickets today!

Categories: Blogs

Platform.sh: More flexible elastic now available

Drupal Planet - March 27, 2017 - 10:00pm

Elasticsearch is one of the most popular Free Software search engines available. It’s fast, flexible, and easy to work with.

It’s also now fully up to date on Platform.sh.

Categories: Blogs

Pages