WordPress modern development
-
Upload
roman-vesely -
Category
Software
-
view
131 -
download
0
Transcript of WordPress modern development
better!Do it
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...
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.
$ 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?
Too many files to handle.Manual upload through FTP?
Try to remember everything. There is also another dark side of this process...
$ 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.
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.
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.
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.
$ 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...
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).
Part of composer.json file. You can see custom composer repository or custom install paths.
Project structure and part of a configuration file.
Deployment can be made via several tools like Trellis, ruby-based Capistrano or via ssh access with just two commands.
1 project2+ 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.
+● 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