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

Zend Framework Blog:
Announcement: ZF repository renamed!
May 05, 2016 @ 09:57:16

The Zend Framework blog has a post announcing the name change of the main Zend Framework repository on GitHub:

Per the GitHub documentation on renames, existing links will be automatically redirected, and will persist as long as we do not create a new repository with the name "zf2". Redirects occur for: issues, wikis, stars, followers and git operations.

The post also includes the instructions on how to update your current "remotes" in your git checkout (so you don't have to re-clone). It also mentions the change and how it relates to Composer - hint: nothing at all because of how Composer works.

tagged: zendframework2 repository rename zendframework announcement github

Link: http://framework.zend.com/blog/2016-05-03-zf-repo-rename.html

Zend Framework Blog:
Announcement: ZF repository rename 2016-05-03
Apr 28, 2016 @ 13:08:27

An announcement has been made on the Zend Framework blog today about a massive repository rename that will be happening May 3rd, 2016 to move away from the "zf2" naming.

In contrast to Zend Framework 2, which was a complete rewrite and break with the architecture of Zend Framework 1, the Zend Framework 3 initiative is more of an evolutionary change. [...] Another way of putting it: changes to the main repository are happening incrementally, and version 3 will just be a new major version update within the existing repository. However, such evolutionary change poses a slight logistical problem: the repository is currently named "zf2".

In order to make the change to Zend Framework 3 (and beyond) simpler, the repository will be renamed to "zendframework" instead. In the current configurations this namespace already exists and points to the correct locations so, ideally, no changes will need to be made on the Composer installations of current users - just updates to git remote entries to point to the new locations.

tagged: zendframework zendframework2 zendframework3 repository rename

Link: http://framework.zend.com/blog/2016-04-27-zf2-repo-rename.html

Matthew Weier O'Phinney:
Benefits of multiple repositories (Zend Framework)
Apr 26, 2016 @ 12:09:34

Matthew Weier O'Phinney, of Zend and the Zend Framework project, has put together a Storify stream of tweets he posted about some of the benefits of having multiple repositories in a project.

I've seen a number of critiques and write-ups recently about how monolithic repositories are intrinsically better for developing large projects than using a multi-repository approach. In the past year, we went the other direction, splitting our monolithic repository into individual component repositories, each with their own history, tests, and documentation. This is a summary of our experience.

He goes through a list of six different things they learned as a part of splitting up the (Zend) framework into multiple repositories instead of one monolithic one. He includes the contents of each Tweet and a paragraph or two giving it a bit more context and some examples of the changes that were involved. There's also a bit in there about changes they made to the documentation for the project as a result of these repository splits.

I'm quite happy with the switch from a monolithic repository to individual component repositories. I think our code quality is improving dramatically as a result, and I'm excited about the future of these various code bases.
tagged: multiple repository storify twitter zendframework learn process

Link: https://storify.com/mwop/zf-components

Leonid Mamchenkov:
Adventure in composer private repositories
Apr 22, 2016 @ 09:19:44

In this new post to his site Leonid Mamchenkov talks about some of his "adventure with Composer private repositories" in some of his deployment work with CakePHP 3 applications.

As good as the Packagist is, there is often a need for a repository or a package elsewhere. Whether it’s a commercial library, or sensitive corporate code, having an ability to store it outside of public eye and handle with the same ease and the same tool as the rest of the dependencies is a very welcome feature.

[...] We are setting up similar development and deployment process, but now for CakePHP-based projects. Things are much easier, since CakePHP 3 natively supports composer for the application itself and for its plugins. But we still have the need for private repositories here and there, so we follow the same setup as we did for WordPress.

Unfortunately he was getting a RuntimeException when he was trying to pull in a plugin through the same private repository workflow. Not only had he not seen the error before but the autoloader was configured as defined and other plugins were working with the same structure. As it turns out, it was the composer.json of the main application repository that was the problem. He includes the fix he made to the configuration on a sample CakePHP 3 project, showing how to switch it to a "vcs" type for more correct handling.

tagged: composer private repository issue runtime exception composerjson configuration

Link: http://mamchenkov.net/wordpress/2016/04/21/adventure-in-composer-private-repositories/

Zend Framework Blog:
Issues, Tags, and Closures (oh my)
Apr 14, 2016 @ 10:37:52

On the Zend Framework blog there's an update from Gary Hockin about some GitHub project-level changes that will be happening soon. He'll be doing some housekeeping on the current list of open issues in the main zf2 repository.

I want to make you aware of some upcoming changes to the issues that are currently logged in GitHub. We currently have 426 open issues that are logged against the (now) meta zf2 repository. The vast majority of these are now in the wrong place, as we've split our once monolithic single repository into the many single component repositories. These issues should be moved from the zf2 repository to the correct component that the issue relates to.

He's closed some issues in preparation and tagged others with a "To Be Closed" tag for later handling. By early May all issues tagged "To Be Closed" will be finished out and/or moved to the correct locations. This will leave the project with around 100 issues to manage and to move to the right locations.

tagged: zendframework2 github repository issues closing tagged

Link: http://framework.zend.com/blog/2016-04-11-issue-closures.html

The Repository Pattern in Laravel 5
Mar 15, 2016 @ 12:50:05

The TutsPlus.com site has posted a tutorial covering the use of the repository design pattern in Laravel, a popular PHP framework. While the article does introduce some of the basics of the design pattern, a bit more research may be in order if you're not familiar with its base concepts.

The repository pattern was introduced for the first time by Eric Evans in his Domain-Driven Design book. The repository is, in fact, the entry point for the application to access the domain layer.

To put it simply, the repository allows all your code to use objects without having to know how the objects are persisted. The repository contains all the knowledge of persistence, including mapping from tables to objects. This provides a more object-oriented view of the persistence layer and makes the mapping code more encapsulated.

In this article they replace the default storage/persistence method for database records away from the default Eloquent over to Doctrine, a widely used ORM tool. The start with a brief comparison between Eloquent and Doctrine before starting on on a simple "blog" application. They connect Doctrine to Laravel via an "entity manager" and make a basic Doctrine-based model for the Posts and a matching repository/controller implementation. All the code you'll need to implement it is included along with a simple view to take in the post content and display errors if there were any on the save.

tagged: repository designpattern laravel tutorial doctrine eloquent blog

Link: http://code.tutsplus.com/tutorials/the-repository-pattern-in-laravel-5--cms-25464

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/

SitePoint PHP Blog:
Setting up PHP 7 Servers with Laravel Forge and DigitalOcean
Jan 07, 2016 @ 11:11:38

The SitePoint PHP blog has another new article from editor Bruno Skvorc showing you how to set up PHP 7 servers in two different ways: one the DigitalOcean platform and the other using the Laravel Forge service.

In this quick guide, we’ll cover two ways to bring a PHP 7 server online on DigitalOcean – a popular VPS provider. We’ll use two approaches, the latter of which will be applicable to any Ubuntu installation whereas the former will only work on DigitalOcean.

He starts with a brief description of what Laravel Forge is for those not familiar with it and how to use it to set up your new server instance. Screenshots of the interface are included showing the setup of the instance, backups, configuration of the server and how to link it to a repository. Then he gets into the more "manual" installation, working with a simple low-tier DigitalOcean droplet to secure and configure it with similar kinds of features: PHP 7 installed and working, Nginx and a fresh checkout of the repository.

tagged: php7 server tutorial setup laravelforge digitalocean deploy repository

Link: http://www.sitepoint.com/setting-up-php-7-servers-with-laravel-forge-and-digitalocean/

Doctrine ORM and Laravel 5
Nov 19, 2015 @ 10:55:39

On the NetTuts site there's a tutorial posted helping you get familiar with Doctrine 2 (the ORM) and how to integrate it with a Laravel 5 application via a simple service provider.

As a PHP developer, you might have come across the term ORM. ORM is a way to work with databases in the same way you work with classes and objects. If you were to delve deeper into how web applications are designed and built, after doing some exploring in their ORM you would find two well-known patterns: Active Record and Data Mapper.

[...] With Data Mapper the in-memory objects needn’t know that there is even a database present. They need no SQL interface code or knowledge of the database schema. One such solution is Doctrine.

The tutorial walks you through some of the basic concepts in using the Doctrine 2 ORM including Entities and Repositories. Also included is how to pull it in via Composer and update your Laravel configuration to use this bridge library for integrating it into your current application. Code examples are included showing you how to build out an entity, repository and a validator class for a basic blog post.

tagged: introduction integration tutorial laravel orm doctrine2 entity repository validator

Link: http://code.tutsplus.com/tutorials/doctrine-orm-and-laravel-5--cms-24914

Jon LeMaitre:
Separation of Concerns with Laravel’s Eloquent (Series)
Nov 10, 2015 @ 09:10:47

Jon LeMaitre has written up a series of posts talking about effective separation of concerns using Eloquent, the database access component of the Laravel framework. His goal is to show you how makes use of the library and keep your application both maintainable and readable.

Eloquent (and by extension, Laravel) is often criticized because of its ActiveRecord ORM implementation, and that DataMapper produces a cleaner, more maintainable architecture in the long run. [...] This combination of behaviors crammed into a single object in itself is not the problem (in fact, it’s a wonderful asset), the problem is in how you make use of those behaviors throughout your application. You can be sloppy with them, or you can be tidy with them.

He starts with the "sloppy approach" where different methods of accessing the objects (and their data) are spread all across the application. He counters this with the tidy approach that makes use of "persistence-agnostic 'POPOs'" to hide the logic behind repositories. In the second part of the series he starts in and puts this idea into practice, using a simple "Member" table and model and repository classes to abstract the logic. Finally, in part three he gets into some more extended functionality for the repositories approach: handling collections, relations, eager loading and schema changes.

tagged: laravel eloquent designpattern repository orm datamapper activerecord abstraction tutorial series

Link: https://medium.com/laravel-news/separation-of-concerns-with-laravel-s-eloquent-part-1-an-introduction-c9a6dc6b4a65#.o0qsccqos