anchour / bedrock
A modern WordPress stack
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1 148
Open Issues: 0
Type:project
Requires
- php: >=5.4
- composer/installers: v1.0.12
- fancyguy/webroot-installer: 1.1.0
- vlucas/phpdotenv: ~1.0.6
- wordpress/wordpress: 4.5.1
- wpackagist-plugin/backwpup: ~3.1
- wpackagist-plugin/cms-tree-page-view: ~1.3
- wpackagist-plugin/iwp-client: ~1.5
- wpackagist-plugin/jetpack: ~4.0
- wpackagist-plugin/sendgrid-email-delivery-simplified: ^1.8
- wpackagist-plugin/simple-301-redirects: ~1.0
- wpackagist-plugin/wordfence: ~6.0
- wpackagist-plugin/wordpress-seo: ~3.0
- wpackagist-plugin/wp-super-cache: ~1.4
- dev-master
- 1.4.4
- 1.4.3
- 1.4.2.1
- 1.4.2
- 1.4.1
- 1.4.0.2
- 1.4.0.1
- 1.4.0
- 1.3.19
- 1.3.18
- 1.3.17
- 1.3.16
- 1.3.15
- 1.3.14
- 1.3.13
- 1.3.12
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- dev-develop
- dev-feature/new-env-configuration
- dev-disallow-indexing
- dev-autoloader
- dev-mu-plugins
- dev-remove-url-env-vars
This package is not auto-updated.
Last update: 2023-06-10 09:23:18 UTC
README
Version: 1.4.3
Bedrock is a modern WordPress stack that helps you get started with the best development tools and project structure.
This is a fork of Roots, modified to use with deploying sites via Laravel Forge.
What's This For?
This package is intended for use with Laravel Forge. Forge allows you to provision servers that are primarily used with Laravel, but allow you to deploy really anything you want. It comes with:
- Nginx
- PHP 5.5
- MySQL
and more, pre-installed.
Quick Start
Run composer create-project anchour/bedrock <path>
(see Installation/Usage for more details)
Features
- Dependency management with Composer
- Better folder structure
- Easy WordPress configuration with environment specific files
- Environment variables with Dotenv
Requirements
- Git
- PHP >= 5.3.2 (for Composer)
Installation/Usage
See Documentation for more details on the steps below.
Using create-project
Composer's create-project
command will automatically install the Bedrock project to a directory and run composer install
.
The post-install-cmd
and post-root-package-install
scripts will automatically create .env
and prompt you about generating salt keys.
Note: To generate salts without a prompt, run create-project
with -n
(non-interactive). You can also change the generate-salts
setting in composer.json
under config
in your own fork. The default is true
.
To skip the scripts completely, create-project
can be run with --no-scripts
to disable it.
- Run
composer create-project anchour/bedrock <path>
(path
being the folder to install to) - Add theme(s)
- Access WP Admin at
http://example.com/wp/wp-admin
- Set your Nginx or Apache vhost to
/path/to/site/public/
.
Manually
- Clone/Fork repo
- Run
composer install
- Add theme(s)
- Access WP Admin at
http://example.com/wp/wp-admin
- Set your Nginx or Apache vhost to
/path/to/site/public/
.
Documentation
Folder Structure
├── composer.json
├── config
│ ├── environments
│ │ ├── development.php
│ │ ├── staging.php
│ │ └── production.php
│ └── application.php
├── Gemfile
├── vendor
└── web
├── app
│ ├── mu-plugins
│ ├── plugins
│ └── themes
├── wp-config.php
├── index.php
└── wp
The organization of Bedrock is similar to putting WordPress in its own subdirectory but with some improvements.
- In order not to expose sensitive files in the webroot, Bedrock moves what's required into a
public/
directory including the vendor'dwp/
source, and thewp-content
source. wp-content
(or maybe justcontent
) has been namedapp
to better reflect its contents. It contains application code and not just "static content".wp-config.php
remains in thepublic/
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 undervendor
due to WP limitations.
Configuration Files
The root public/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
, staging
, 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
.
Note: You can't re-define constants in PHP. So if you have a base setting in application.php
and want to override it in production.php
for example, you have a few options:
- Remove the base option and be sure to define it in every environment it's needed
- Only define the constant in
application.php
if it isn't already defined.
Don't want it?
You will lose the ability to define environment specific settings.
- Move all configuration into
wp-config.php
- Manually deal with environment specific options
- Remove
config
directory
Environment Variables
PHP dotenv is used to load the .env
file. All variables are then available in your app by getenv
, $_SERVER
, or $_ENV
. The post-install-cmd
and post-root-package-install
scripts will automatically generate and set your salts in .env
when:
- The
.env
file doesn't exist - The
.env
file exists, but doesn't contain anything.
Another benefit of Forge is the ability to set environment variables within the UI. The required vars are as follows.
- DB_USER
- DB_NAME
- DB_PASSWORD
Both the .env
variables and the ones set within the UI are available in $_ENV
.
Don't want it?
You will lose the separation between config and code and potentially put secure credentials at risk.
Composer
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
Plugins
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
, and mu-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:
!public/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 WP and plugin versions
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.
Themes
Themes can also be managed by Composer but should only be done so under two conditions:
- You're using a parent theme that won't be modified at all
- You want to separate out your main theme and use that as a standalone package
Under most circumstances we recommend NOT doing #2 and instead keeping your main theme as part of your app's repository.
Just like plugins, WPackagist maintains a Composer mirror of the WP theme directory. To require a theme, just use the wpackagist-theme
namespace.
Don't want it?
Composer integration is the biggest part of Bedrock, so if you were going to remove it there isn't much point in using Bedrock.
wp-cron
Bedrock disables the internal WP Cron via define('DISABLE_WP_CRON', true);
. If you keep this setting, you'll need to manually set a cron job like the following in your crontab file:
*/5 * * * * curl http://example.com/wp/wp-cron.php
WP-CLI
Bedrock works with WP-CLI just like any other WordPress project would. Previously we required WP-CLI in our composer.json
file as a dependency. This has been removed since WP-CLI now recommends installing it globally with a phar
file. It also caused conflicts if you tried using a global install.
The wp
command will automatically pick up Bedrock's subdirectory install as long as you run commands from within the project's directory (or deeper). Bedrock includes a wp-cli.yml
file that sets the path
option to public/wp
. Use this config file for any further configuration.
Contributing
Everyone is welcome to help contribute and improve this project. There are several ways you can contribute:
- Reporting issues (please read issue guidelines)
- Suggesting new features
- Writing or refactoring code
- Fixing issues