Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Symfony Finland:
Choosing a front end architecture for Symfony framework projects
Aug 01, 2016 @ 11:21:42

On the Symfony Finland site there's a new post with some suggestions on choosing a frontend for your Symfony-based applications according to your needs.

Most projects created with the Symfony framework nowadays also include quite a bit of logic done on the client side. There is a large number of options on the market and this can lead to trouble choosing between the options. The JavaScript scene is full of camps and cutting through the buzz is quite a bit of work. [...] Symfony remains neutral to what is running in the front end of the project. As with most things in web development, there is no single "right" answer to which front end frameworks to use.

They talk briefly about the history of the framework and what kinds of considerations should be made for both the front and backend technology. They also remind you that there's not a "one size fits all" frontend technology out there. They describe a few different kinds of situations (backend heavy, frontend heavy, etc) and make a few suggestions as to which way you might want to go and libraries to investigate.

The next time you're faced with starting work on a front end of a web site or web application built with Symfony, you can reflect on the experience you've got from the back end. There are usually many right answers and no absolute truths.
tagged: frontend architecture symfony application suggestion opinion project

Link: https://www.symfony.fi/entry/choosing-a-front-end-architecture-for-symfony-framework-projects

Paul Jones:
Why Do PHP Developers Think MVC Is An Application Architecture?
Mar 16, 2016 @ 11:49:51

In a new post to his site Paul Jones wonders out loud about why developers think MVC is an application architecture versus just a user interface pattern.

I’ve pointed out before that Model-View-Controller is a user interface pattern, not an application architecture. But why would PHP developers get the idea that MVC is an application architecture in the first place?

[...] I used to think that MVC was an application architecture. Even after reading Fowler’s POEAA and seeing that MVC was for the user interface, I figured that meant I was doing “user interface applications.” But that was not quite right; it would have been more accurate to say that I had been mixing the concerns of user interface with the underlying core application.

He suggests that the reason MVC is commonly thought of as an architecture is because of the "flow" most PHP developers follow in their learning and development practices. Starting from "page scripts" where things are all mashed together, a developer then learns about the separation of concerns and how MVC helps splitting up the application easier. Paul includes a reminder, though, that the "user interface" isn't really just the frontend parts (HTML, CSS, JS) but the HTTP request/response to and from the application.

tagged: mvc modelviewcontroller application architecture progression developer opinion

Link: http://paul-m-jones.com/archives/6288

Paul Jones:
Command Bus and Action-Domain-Responder
Mar 10, 2016 @ 10:53:47

In this post to his site Paul Jones looks at the combination of the Action-Domain-Responder pattern and the Command Bus pattern in application development. In the post he answer the question about how they fit together.

Over the past few weeks, different people have asked me where a Command Bus goes in an Action-Domain-Responder system. While I’m not a DDD expert, after brushing up on the subject a little, my answer is: "In the Domain."

He starts by reviewing the three pieces of the ADR pattern with brief descriptions of each. The then covers the Command Bus pattern, linking to several other resources with more details about the pattern itself and a quick summary of their main points. He talks about how the overall structure is a part of the Command Query Responsibility Segregation pattern and suggests that, since the Command Bus pattern is a "fire and forget" kind of thing it belongs in the Domain of ADR. He gives a brief code example and answers other questions about validation and error handling as a part of this suggested flow.

tagged: action domain responder adr commandbus architecture suggestion

Link: http://paul-m-jones.com/archives/6268

SitePoint PHP Blog:
Clean Code Architecture and Test Driven Development in PHP
Feb 09, 2016 @ 09:13:28

The SitePoint PHP blog has an article posted by Vitalij Mik showing you how to merge the concepts of "clean code architecture" and test-driven development to make solid, maintainable code. The ideals of the "clean code architecture" were first proposed by Robert C. Martin in this post on the 8thlight blog.

The idea was to create an architecture which is independent of any external agency. Your business logic should not be coupled to a framework, a database, or to the web itself. [...] Frameworks will continue to change and evolve. With composer, it is easy to install and replace packages, but it is also easy to abandon a package (composer even has the option to mark a package as abandoned), so it is easy to make “the wrong choice”.

In this tutorial, I will show you how we can implement the Clean Code Architecture in PHP, in order to be in control of our own logic, without being dependent on external providers, but while still using them. We will create a simple guestbook application.

He starts with a first test, evaluating that a list of entries for the guestbook is empty. The code shows the "fakes" for the different object types Uncle Bob recommended in his article and how it fails because none of them exist yet. He extends this with a "can see entries" test and then starts in on the "use case" class to start making the test pass. He updates the case to pull in entries from the repository, another external dependency created later in the tutorial. He then goes through creating the classes for the "fakes" in the test and refactoring the test based on some of his changes during their development. In the remainder of the post he talks about the independence of the current setup and how to add in pagination functionality on the entries objects.

tagged: cleancode architecture testdriven development tdd tutorial entity repository decouple

Link: http://www.sitepoint.com/clean-code-architecture-and-test-driven-development-in-php/

Derick Rethans:
New MongoDB Drivers for PHP and HHVM: Architecture
Jan 12, 2016 @ 09:37:59

Derick Rethans continues his look at the latest version of the MongoDB drivers for both PHP and HHVM with this look at their architecture and how it's different from previous versions.

We recently released a new version of the MongoDB driver for PHP (the mongodb extension). This release is the result of nearly a year and a half of work to re-engineer and rewrite the original MongoDB driver (mongo). In the previous blog post, I covered the back story of the how and why we undertook this effort. In this new blog post, I will talk about the architecture of the new driver.

He uses the goals stated at the end of his previous post and covers:

  • Support for Other PHP Engines like HHVM
  • [How/Why] The Driver Should Be Bare Bones
  • No Reinvention of the Wheel
  • Provide an Easy to Use API
  • Backwards Compatibility

From there he then gives an overview (complete with a handy graphic) of the overall MongoDB PHP ecosystem and where the extensions fit in the plan.

tagged: mongodb derickrethans drivers hhvm architecture series part2

Link: http://derickrethans.nl/new-drivers-part2.html

Laravel and Vue JS: Advanced Frontend Webapp Architecture
Jul 17, 2015 @ 08:46:10

On Medium.com Russ Weas has posted a tutorial showing you how to get Laravel and Vue.js working together to create a well-structured, two-way application.

Do you use Laravel PHP and Vue JS? Do you wish there was a better way to structure your applications you build? This tutorial is just for you! In it, we set up simple two-way communication between the different components of your front-end app.

While he does provide the end result as a GitHub repository, he still walks through the full integration process to fill in the gaps. He starts with a brief introduction to a Vue.js application structure (based off of this video) and what parts need to be in play to follow along. From there he gets into the two-way communication aspect, showing how to create the bridge between the application, its views and components. He talks about some of the "missing pieces" of the current structure including an update to pass in a dependency injection "container" on the Vue side similar to how Laravel's IOC container works.

The remainder of the post is split into three parts, each with an update to the view layer (on the client side) to work with the new IOC structure:

  • using this.app in each view
  • setting data for a particular view from other views or the main app
  • calling view functions

He concludes the post with the full code for the two files they've been working with, showing everything working together: the HTML template (Laravel view) and the "app.js" Javascript for the Vue.js code.

tagged: laravel tutorial architecture vuejs frontend framework

Link: https://medium.com/laravel-news/advanced-front-end-setup-with-vue-js-laravel-e9fbd7e89fe2

Laravel Podcast:
Episode 30: Trouble, Trouble, Trouble...
Jun 25, 2015 @ 08:50:41

The Laravel Podcast, hosted by Matt Stauffer (with regular guests Taylor Otwell and Jeffrey Way) has posted their latest episode today - Episode #30: Trouble, Trouble, Trouble....

In this episode, the crew discusses architecture driven religious wars and the recent drama surrounding Apple Music.

You can listen to this latest episode either through the in-page audio player, by downloading the mp3 or by subscribing to their feed to get this and future episodes as they're released. Be sure to also follow them on Twitter for announcements when new episodes are released.

tagged: laravel podcast ep30 trouble architecture religious war apple music

Link: http://www.laravelpodcast.com/episodes/13327-episode-30-trouble-trouble-trouble

MongoDB Blog:
Call for Feedback: The New PHP and HHVM Drivers
Mar 12, 2015 @ 11:33:23

The MongoDB blog has a new post asking for feedback on what the user community thinks of their approach to supporting MongoDB functionality in PHP 5.x, HHVM and even out to PHP7.

Since the PHP driver first appeared on the scene, MongoDB has gone through many changes. [...] Beyond MongoDB's features, our ecosystem has also changed. [...] During the spring of 2014, we worked with a team of students from Facebook's Open Academy program to prototype an HHVM driver modeled after the 1.x API.

[...] Although the final result was not feature complete, the project was a valuable learning experience. The C driver proved quite up to the task, and HNI, which allows an HHVM extension to be written with a combination of PHP and C++, highlighted critical areas of the driver for which we'd want to use C. This all leads up to the question of how best to support PHP 5.x, HHVM, and PHP 7.0 with our next-generation driver.

They've shared the overview of the new driver structure including three layers: the system level functionality, the extensions themselves and a MongoDB userland library. They walk through the thinking on each of the pieces of the puzzle and how they all couple together to make for a more robust, flexible system that's also easy to use.

tagged: mongodb drivers extension mongo userland library architecture opinion feedback

Link: http://www.mongodb.com/blog/post/call-feedback-new-php-and-hhvm-drivers

A Journey into Microservices
Mar 11, 2015 @ 11:23:34

On the Hailo.com blog Matt Heath has posted a series of articles about their transition from a "monolith" codebase out into a set of microservices for the Hallo app system.

Hailo, like many startups, started small; small enough that our offices were below deck on a boat in central London - the HMS President. Working on a boat as a small focused team, we built out our original apps and APIs using tried and tested technologies, including Java, PHP, MySQL and Redis, all running on Amazon's EC2 platform. [...] After we launched in London, and then Dublin, we expanded from one continent to two, and then three; launching first in North America, and then in Asia. This posed a number of challenges-the main one being locality of customer data.

They describe this customer data problem in a bit more detail with the issue mostly revolving around the geolocation of the user and their information. They talk about "going global" and the steps they took to make the move. In the three parts of the series, they explain the changes they made and why they were effective for their application:

They end the series with some links to other resources that help compliment the subjects mentioned and link to slides from a presentation around the same topic.

tagged: microservice journey series part1 part2 part3 introduction architecture api halloapp

Link: https://sudo.hailoapp.com/services/2015/03/09/journey-into-a-microservice-world-part-1/

Programming Are Hard:
Structuring my applications
Mar 06, 2015 @ 11:25:54

On the Programming Are Hard site there's a recent post looking at PHP application structure and how they handled the structure of one of their applications.

One of the biggest struggles for me, as an app developer, is coming up with an architecture that I'm happy with. It's something I wish other developers talked about more often. I thoroughly enjoyed Kris Wallsmith's SymfonyCon talk. It's very raw and real and doesn't come across as him talking down to anyone at all. Do I agree with everything he says? No, but that's not a bad thing. It's very insightful and I really enjoy taking a peak behind the curtains and seeing how other people do things. This is my attempt at doing just that.

He's broken down the structure into the overall parts and provided examples and summaries of each:

  • The use of packages
  • Entities
  • Events and Event Listeners
  • Commands and Handlers
  • Exceptions
  • Providers
  • Repositories
  • Security functionality
  • Services
  • Testing
  • Validation
  • Value Objects

Each section includes sample code and a description of where in the overall directory structure it fits. The setup is largely based on a Symfony application but it can be extracted (since it's mostly concepts) to most frameworks out there, even custom ones.

tagged: application architecture structure symfony tutorial example

Link: http://programmingarehard.com/2015/03/04/structing-my-application.html