Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress modern development

WordPress modern development

How not to lose your head at work with WordPress by using tools common in today's PHP development. Tools like git and composer may help you develop more maintainable applications.

Roman Veselý

November 18, 2016
Tweet

Other Decks in Programming

Transcript

  1. After dozens projects based on WordPress I found I miss

    something important. This is the solution (or one among the others), but let's do some introduction at first...
  2. famous 5-minute installation WP is famous because of its simplicity

    when even BFU can easily start a project (which is great). One can download a ZIP, decompress, upload, and start working. It has automatic updates and web based plugin/themes installation. Such a simple one-click-to-profit process may however lead to irregularities in the future.
  3. $ git init We can start to use git to

    allow cooperation in dev team and also to prevent conflicts between develop and production environments. But how will the commits and pull requests look like? What about third-party dependencies?
  4. Too many files to handle. Manual upload through FTP? Try

    to remember everything. There is also another dark side of this process...
  5. $ composer init Move on and start to use PHP

    package manager. What can be a package in WP world? Plugin, theme and even a WordPress core itself.
  6. https://github.com/WordPress/WordPress https://wpackagist.org/ WP is not prepared for composer. To get

    plugins and themes we can thankfully use their mirror with composer.json files included. Problem is their installation destination - vendor folder by default, where WP doesn’t look.
  7. johnpbloch/wordpress custom install paths There is an unofficial mirror also

    for the WordPress core with composer.json file. WordPress’ dependencies are special types of packages, so we can change their destination thanks to the composer custom paths.
  8. wordpress-plugin wordpress-theme wordpress-muplugin There is a plenty of custom packages

    types. Muplugin stands for must-use, a special type of a plugin that cannot be deactivated.
  9. $ composer create-project roots/bedrock project-name Again, too much to remember.

    Bedrock is a boilerplate for your WP projects. It has all features we mentioned so far included. And adds something more...
  10. environments wp-config.php → .env wp-password-bcrypt md5 → bcrypt Bedrock supports

    different configuration for more environments (development, testing, production, …). It also ships with a plugin that makes users’ passwords more secure (can be used also on a project which is not based on Bedrock).
  11. Deployment can be made via several tools like Trellis, ruby-based

    Capistrano or via ssh access with just two commands.
  12. 1 project 2+ repositories You can split your project into

    (at least) two repositories. One with defined dependencies like WP core and third-party plugins. The second is for your custom theme. More might come when you develop your own plugins.
  13. + • Less amount of manual work • Cleaner repositories

    • Easier code review • Overview of dependencies and their versions - composer.json • Simplified deployment - • Need to change old habits • Time to set a new routine • Automatic updates