WordPlate is a boilerplate for WordPress, built with Composer and designed with sensible defaults.
-
WordPress + Composer = ❤️
WordPress can be installed and updated with ease using Composer. To update WordPress, simply run the command
composer update. -
Environment Files
Similar to Laravel, WordPlate stores environment variables, such as database credentials, in an
.envfile. -
WordPress Packagist
WordPress Packagist enables the management of WordPress plugins and themes through Composer.
-
Must-use plugins
Don't worry about clients deactivating plugins; must-use plugins are enabled by default.
-
Vite.js
Using Vite, you can rapidly set up and begin building and minifying your CSS and JavaScript.
-
Tailwind CSS
Tailwind CSS is included by default, allowing you to quickly build custom designs.
-
Debugging
Familiar debugging helper functions are integrated such as
dump()anddd(). -
Clean UI
Enhance the WordPress dashboard and improves the user experience for clients.
Before using WordPlate, make sure you have PHP 8.2 and MySQL 8.0 installed on your computer. You'll also need to have Composer, a package manager for PHP, installed on your computer.
To install WordPlate, open your terminal and enter the following command:
composer create-project --prefer-dist vinkla/wordplate example-appAfter installing WordPlate, you'll need to update the database credentials in the .env file. This file is located in the root directory of your project. Open the file and update the following lines with your database credentials:
DB_NAME=database
DB_USER=username
DB_PASSWORD=passwordTo run your WordPlate application, you may serve it using PHP's built-in web server. Open your terminal and navigate to the public directory of your project. Then, enter the following command:
php -S 127.0.0.1:8000 -t public/Finally, open your web browser and visit the following URLs to view your WordPlate application:
http://127.0.0.1:8000/- Your websitehttp://127.0.0.1:8000/wordpress/wp-admin- The dashboard
After installing WordPlate, you'll need to configure your web server's document or web root to be the public directory. This is where the main entry point for your application, index.php, is located.
By setting the public directory as your web server's document root, you ensure that all HTTP requests are routed through the front controller, which handles the requests and returns the appropriate responses.
This configuration helps to improve the security and performance of your application by preventing direct access to files outside of the public directory.
WordPlate makes it easy to manage different configuration values based on the environment where your application is running. For example, you may need to use a different database locally than you do on your production server.
To accomplish this, WordPlate uses the vlucas/phpdotenv PHP package. When you install WordPlate, a .env.example file is included in the root directory of your application. If you installed WordPlate via Composer, this file will automatically be renamed to .env. Otherwise, you should rename the file manually.
It's important to note that your .env file should not be committed to your application's source control. This is because each developer or server using your application may require a different environment configuration. Additionally, committing your .env file to source control would be a security risk in the event that an intruder gains access to your repository, as any sensitive credentials would be exposed.
To learn more about managing environment variables in WordPlate, you can refer to Laravel's documentation on the topic:
It's important to add salt keys to your environment file. These keys are used to encrypt sensitive data, such as user sessions, and help to ensure the security of your application.
If you don't set the salt keys, your user sessions and other encrypted data may be vulnerable to attacks. To make it easier to generate secure salt keys, we've created a salt key generator that you can use. If you haven't already done so, copy the .env.example file to a new file named .env. Then visit the generator and copy the randomly generated keys to your .env file.
WordPlate includes integration with WordPress Packagist, a Composer repository that mirrors the WordPress plugin and theme directories. With this integration, you can install and manage plugins using Composer.
To install a plugin, use wpackagist-plugin as the vendor name and the plugin slug as the package name. For example, to install the clean-image-filenames plugin, you would use the following command:
composer require wpackagist-plugin/clean-image-filenamesThe installed packages will be located in the public/plugins directory.
Here's an example of what your composer.json file might look like:
"require": {
"wpackagist-plugin/clean-image-filenames": "^1.5"
}For more information and examples, please visit the WordPress Packagist website.
Must-use plugins (also known as mu-plugins) are a type of WordPress plugin that is installed in a special directory inside the content folder. These plugins are automatically enabled on all sites in the WordPress installation.
To install plugins into the mu-plugins directory, add the plugin name to the installer-paths of your composer.json file:
"installer-paths": {
"public/mu-plugins/{$name}": [
"type:wordpress-muplugin",
"wpackagist-plugin/clean-image-filenames",
]
}To install the plugin, use wpackagist-plugin as the vendor name and the plugin slug as the package name:
composer require wpackagist-plugin/clean-image-filenamesThe plugin will be installed in the public/mu-plugins directory.
For more information on the must-use plugin autoloader, please refer to the Bedrock documentation.
An easy-to-swallow painkiller plugin for WordPress. It removes a lot of default WordPress stuff you just can't wait to get rid of. It removes meta tags such as feeds, version numbers and emojis.
The plugin automatically converts language accent characters in filenames when uploading to the media library. Characters are converted into browser and server friendly, non-accent characters.
Räksmörgås.jpg→raksmorgas.jpgÆblegrød_FTW!.gif→aeblegrod-ftw.gifChâteau de Ferrières.png→chateau-de-ferrieres.png
Vite is a build tool that provides a faster and leaner development experience for modern web projects. It comes with sensible defaults and is highly extensible via its Plugin and JavaScript APIs with full typing support.
# Start the dev server...
npm run dev
# Build for production...
npm run buildLearn more about Vite's backend integration.
To set up custom SMTP credentials for sending emails in your WordPlate application, you need to configure the required environment variables in your .env file.
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="Example"If you're using a local email service like Mailhog or Mailpit, you need to disable encryption by setting the MAIL_ENCRYPTION environment variable to null.
Can I add WordPress constants to the environment file?
This is possible by updating the public/wp-config.php file after the WordPlate application have been created.
define('WP_DISABLE_FATAL_ERROR_HANDLER', env('WP_DISABLE_FATAL_ERROR_HANDLER', false));
+define('WP_ALLOW_MULTISITE', env('WP_ALLOW_MULTISITE', true));Then you may add the constant to the .env file.
WP_DEFAULT_THEME=wordplate
+WP_ALLOW_MULTISITE=trueCan I disable WP-Cron and set up a manual cron job?
WordPlate allows you to disable the internal WordPress cron system via the DISABLE_WP_CRON environment variable:
DISABLE_WP_CRON=trueIt is recommended to manually set a cron job if you enable this setting and disable the WordPress cron. You'll need to add the following in your crontab file:
*/5 * * * * curl https://exempel.se/wordpress/wp-cron.phpCan I install languages with Composer?
If you want to install language packs using Composer, we recommend looking at the WP Languages project. Below is an example of a composer.json file that installs the Swedish language pack for WordPress.
{
"require": {
"koodimonni-language/core-sv_se": "*",
},
"repositories": [
{
"type": "composer",
"url": "https://wp-languages.github.io",
"only": [
"koodimonni-language/*"
]
}
],
"config": {
"allow-plugins": {
"koodimonni/composer-dropin-installer": true
},
},
"extra": {
"dropin-paths": {
"public/languages/": [
"vendor:koodimonni-language"
]
}
}
}Can I rename the public directory?
Update your .gitignore, composer.json, .vite.config.js, and wp-cli.yml files with the new path to the public directory. Then, run composer update in the root of your project.
Can I rename the WordPress directory?
By default WordPlate will put the WordPress in public/wordpress. If you want to change this there are a couple of steps you need to go through. Let's say you want to change the default WordPress location to public/wp:
-
Update the
wordpress-install-dirpath in yourcomposer.jsonfile. -
Update
wordpresstowpinwordplate/public/.gitignore. -
Update the last line in the
public/index.phpfile to:require __DIR__.'/wp/wp-blog-header.php';
-
Update the
WP_DIRenvironment variable in the.envfile towp. -
If you're using WP-CLI, update the path in the
wp-cli.ymlfile topublic/wp. -
Remove the
public/wordpressdirectory if it exist and then runcomposer update.
Can I rename the theme directory?
For most applications you may leave the theme directory as it is. If you want to rename the wordplate theme to something else you'll also need to update the WP_DEFAULT_THEME environment variable in the .env file.
Can I use WordPlate with Laravel Herd?
If you're using Laravel Herd or Valet together with WordPlate, you may use our custom driver:
<?php
namespace Valet\Drivers\Custom;
use Valet\Drivers\BasicValetDriver;
class WordPlateValetDriver extends BasicValetDriver
{
public function serves(string $sitePath, string $siteName, string $uri): bool
{
return is_dir($sitePath . '/public/wordpress');
}
public function isStaticFile(string $sitePath, string $siteName, string $url)
{
$staticFilePath = $sitePath . '/public' . $url;
if ($this->isActualFile($staticFilePath)) {
return $staticFilePath;
}
return false;
}
public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
{
return parent::frontControllerPath(
$sitePath . '/public',
$siteName,
$this->forceTrailingSlash($uri)
);
}
private function forceTrailingSlash(string $uri)
{
if (substr($uri, -1 * strlen('/wordpress/wp-admin')) === '/wordpress/wp-admin') {
header('Location: ' . $uri . '/');
exit;
}
return $uri;
}
public function logFilesPaths()
{
return [
'/public',
];
}
}Can I use WordPlate with Tinkerwell?
If you're using Tinkerwell together with WordPlate, you may use our custom driver:
<?php
final class WordPlateTinkerwellDriver extends WordpressTinkerwellDriver
{
public function canBootstrap($projectPath)
{
return file_exists($projectPath . '/public/wordpress/wp-load.php');
}
public function bootstrap($projectPath)
{
require $projectPath . '/public/wordpress/wp-load.php';
}
public function appVersion()
{
return 'WordPlate ' . get_bloginfo('version');
}
}Upgrading from 11 to 12
-
The
wordplate/frameworkpackage has been archived. Remove the package from thecomposer.jsonfile:"require": { - "wordplate/framework": "^11.1", } -
Install the following package dependencies:
composer require \ composer/installers \ roots/bedrock-autoloader \ roots/wordpress \ symfony/http-foundation \ vinkla/headache \ vlucas/phpdotenv \ wpackagist-plugin/clean-image-filenames -
Install the following development package dependencies:
composer require --dev symfony/var-dumper
-
Replace your
public/wp-config.phpfile with the one in this repository. Remember to save any custom constants defined in yourwp-config.phpfile. -
Add the
src/helpers.phpfile from this repository and autoload it in thecomposer.jsonfile:+"autoload": { + "files": [ + "src/helpers.php" + ] +}
-
Run
composer updatein the root of your project.
Upgrading from 10 to 11
-
WordPlate now requires PHP 8.0 or later.
-
Bump the version number in the
composer.jsonfile to^11.0. -
Run
composer updatein the root of your project.
Upgrading from 9 to 10
-
WordPlate now requires PHP 7.4 or later.
-
Bump the version number in the
composer.jsonfile to^10.0. -
Rename
WP_ENVtoWP_ENVIRONMENT_TYPEin the environment file. -
Rename
WP_THEMEtoWP_DEFAULT_THEMEin the environment file. -
Rename
WP_URLtoWP_HOMEin the environment file (if it exists). -
If you're using the
WP_CACHEenvironment variable you'll need to define it in thepublic/wp-config.phpfile:$application->run(); +define('WP_CACHE', env('WP_CACHE', false)); $table_prefix = env('DB_TABLE_PREFIX', 'wp_'); -
Optional: Rename
WP_PREFIXtoDB_TABLE_PREFIXin the following files:.env.env.examplepublic/wp-config.php
-
Run
composer updatein the root of your project.
Upgrading from 8 to 9
-
Bump the version number in the
composer.jsonfile to^9.0. -
Copy the
public/mu-plugins/mu-plugins.phpfile into your project. -
Update the
public/.gitignorefile to allow the newmu-plugins.phpfile:-mu-plugins/ +mu-plugins/* +!mu-plugins/mu-plugins.php
-
Run
composer updatein the root of your project.
Upgrading from 7 to 8
-
WordPlate now requires PHP 7.2 or later.
-
Bump the version number in the
composer.jsonfile to^8.0.[!Note]
WordPlate 8.0 requires WordPress 5.3 or later. -
Laravel's helper functions is now optional in WordPlate. If you want to use the functions, install the
laravel/helperspackage, with Composer, in the root of your project:composer require laravel/helpers
-
Laravel's collections are now optional in WordPlate. If you want to use collections, install the
tightenco/collectpackage, with Composer, in the root of your project:composer require tightenco/collect
-
The
mixhelper function is now optional in WordPlate. If you want to use the function, install theibox/mix-functionpackage, with Composer, in the root of your project:composer require ibox/mix-function
-
Replace any usage of
asset,stylesheet_urlandtemplate_urlfunctions with WordPress'sget_theme_file_urifunction. -
Replace any usage of
stylesheet_pathandtemplate_pathfunctions with WordPress'sget_theme_file_pathfunction . -
The
base_pathandtemplate_slugfunctions have been removed. -
Run
composer updatein the root of your project.
Upgrading from 6 to 7
-
Bump the version number in the
composer.jsonfile to^7.0.[!Note]
WordPlate 7.0 requires WordPress 5.0 or later. -
Update the
realpath(__DIR__)torealpath(__DIR__.'/../')in thewp-config.phpfile. -
If your public directory isn't named
public, add the following line to thewp-config.phpfile:$application->setPublicPath(realpath(__DIR__));
-
Run
composer updatein the root of your project.
Upgrading from 5 to 6
-
Bump the version number in the
composer.jsonfile to^6.0. -
Update the
realpath(__DIR__.'/../')torealpath(__DIR__)in thewp-config.phpfile. -
Run
composer updatein the root of your project.
Upgrading from 4 to 5
-
Bump the version number in the
composer.jsonfile to^5.0. -
Copy and paste the contents of the
wp-config.phpfile into your application.[!Note]
Make sure you don't overwrite any of your custom constants. -
Run
composer updatein the root of your project.
WordPlate wouldn't be possible without these amazing open-source projects.
composer/installersmotdotla/dotenvoutlandish/wpackagistroots/bedrock-autoloaderroots/wordpresssymfony/http-foundationsymfony/var-dumpertailwindlabs/tailwindcssupperdog/clean-image-filenamesvinkla/headachevitejs/vitevlucas/phpdotenv
The WordPlate package is open-sourced software licensed under the MIT license.