This is a Wordpress stack for RCDFund.org. It is based on Bedrock and Roots.
- Git
- PHP >= 5.3.2 (for Composer)
- Node >= 0.10.0 (for Grunt)
- Clone repo
- Run
composer installand optionally answer yes when prompted about salts (this will generate.env) - Edit
.env(copy .env.example if you answered no in the previous step) and update environment variables:
DB_NAME- Database nameDB_USER- Database userDB_PASSWORD- Database passwordDB_HOST- Database host (defaults tolocalhost)WP_ENV- Set to environment (development,staging,production, etc)WP_HOME- Full URL to WordPress home (http://rcdfund.org)WP_SITEURL- Full URL to WordPress including subdirectory (http://rcdfund.org/wp)
- Go to
web/app/themes/rcdfundand runnpm installfollowed bygruntto generate assets - Point your Nginx or Apache vhost to
web/ - Access WP Admin at
http://rcdfund.org/wp/wp-adminand follow the usual Wordpress setup
├── config
│ ├── environments
│ │ ├── development.php
│ │ └── production.php
│ └── application.php
├── scripts
│ └── Bedrock
│ └── installer.php
├── vendor
├── web
│ ├── app
│ │ ├── plugins
│ │ └── themes
│ │ └── rcdfund
│ ├── wp-config.php
│ ├── index.php
│ └── wp
├── .env
└── composer.json
The organization is similar to putting WordPress in its own subdirectory but with some improvements.
- In order not to expose sensetive files in the webroot, Bedrock moves what's required into a
web/directory including the vendor'dwp/source, and thewp-contentsource. wp-contenthas been namedappto better reflect its contents. It contains application code and not just "static content". It also matches up with other frameworks such as Symfony and Rails.wp-config.phpremains in theweb/because it's required by WP, but it only acts as a loader. The actual configuration files have been moved toconfig/for better separation.vendor/is where the Composer managed dependencies are installed to.wp/is where the WordPress core lives. It's also managed by Composer but can't be put undervendordue to WP limitations.
The root web/wp-config.php is required by WordPress and is only used to load the other main configs. Nothing else should be added to it.
config/application.php is the main config file that contains what wp-config.php usually would. Base options should be set in there.
For environment specific configuration, use the files under config/environments. By default there's is development and production but these can be whatever you require.
The environment configs are required before the main application config so anything in an environment config takes precedence over application.
Bedrock tries to separate config from code as much as possible and environment variables are used to achieve this. The benefit is there's a single place (.env) to keep settings like database or other 3rd party credentials that isn't committed to your repository.
PHP dotenv is used to load the .env file. All variables are then available in your app by getenv, $_SERVER, or $_ENV.
Currently, the following env vars are required:
DB_USERDB_NAMEDB_PASSWORDWP_HOMEWP_SITEURL
Composer is used to manage dependencies. Bedrock considers any 3rd party library as a dependency including WordPress itself and any plugins.
See these two blogs for more extensive documentation:
Screencast ($): Using Composer With WordPress
WordPress Packagist is already registered in the composer.json file so any plugins from the WordPress Plugin Directory can easily be required.
To add a plugin, add it under the require directive or use composer require <namespace>/<packagename> from the command line. If it's from WordPress Packagist then the namespace is always wpackagist-plugin.
Example: "wpackagist-plugin/akismet": "dev-trunk"
Whenever you add a new plugin or update the WP version, run composer update to install your new packages.
plugins are Git ignored by default since Composer manages them. If you want to add something to those folders that isn't managed by Composer, you need to update .gitignore to whitelist them:
!web/app/plugins/plugin-name
Note: Some plugins may create files or folders outside of their given scope, or even make modifications to wp-config.php and other files in the app directory. These files should be added to your .gitignore file as they are managed by the plugins themselves, which are managed via Composer. Any modifications to wp-config.php that are needed should be moved into config/application.php.
Updating your WordPress version (or any plugin) is just a matter of changing the version number in the composer.json file.
Then running composer update will pull down the new version.