Bedrock Video Tutorial
In this chapter we will discover Bedrock, a starter kit for WordPress which integrates modern development tools and which offers a better folder structure.
The problem with classic WordPress
The main problem we will encounter with a classic WordPress installation is the folder structure. This structure is problematic on several levels:
- The basic structure implies that all files are accessible from the web server (the common practice is to create a folder
publicand place PHP sources one level above)
- The lack of separation prevents versioning because it is necessary to version the code of plugins and core.
What Bedrock brings
Bedrock will partially solve the problems raised above and will also provide some additional functionality.
The first point is the simplification of the installation which can be done through composing
composer create-project roots / bedrock
This command will install WordPress as well as some other small dependencies like roots / wp-password-bcrypt which allows you to change the password hashing method.
Better folder structure
After your installation you will notice that the folder structure is not necessarily that which we are used to encounter.
site/ ├──. Env ├── config / │ ├── environments / │ │ ├── development.php │ │ ├── staging.php │ │ └── production.php │ └── application.php # Primary wp-config.php ├── vendor / # Composer dependencies └── web / # Virtual host document root ├── app / # WordPress content directory │ ├── mu-plugins / │ ├── plugins / │ ├── themes / │ └── uploads / └── wp / # WordPress core
This structure allows to bring more flexibility in the use of WordPress and in its configuration on several environments.
- The folder
webwill serve as the root for our web server. This allows you to place "critical" files one level above the web root and avoids exposing our dependencies but also certain sensitive files.
- The folder
web / wpwill contain the core of WordPress and is automatically generated from composer. This allows you to better control the version of WordPress and to be able to apply constraints on the versions that are supported by the project.
- The folder
configwill contain the configuration of our WordPress with the possibility of changing the configuration depending on the environment used
- The file
.envallows you to configure the project in the absence of an environment variable (this is where we will configure our database, for example).
The work on themes and plugins will be done in the folder
web / app / themes,
web / app / mu-plugins and
web / app / plugins.
WPackagist to manage plugins
An additional deposit is also automatically added to your file
composer.json and allow you to manage your plugins as dependencies on your project. To install a plugin, just search for it on Wpackagist and install it as you would for a classic dependency:
composer require wpackagist-plugin / wp-migrate-db
The plugin will automatically go to the right folder and you just need to activate it. You will also be able to manage its updates using composer and checking the versions that are supported by your application.