Get your project dependencies by executing the following command.
yarn install && composer installStart and initialize the Docker containers.
docker-compose up --buildExecute the provided bash script to automate WordPress installation and plugin activation.
For additional configuration and setup, modify the WP-CLI script found in docker/cli/install-wordpress.
docker-compose run --rm cli install-wordpressAdmin Details
Username: wordpress
Password: wordpress
Compile your assets for production with the command:
npm run buildAccess the WP-CLI with the following commands:
docker-compose run --rm cli wp [command]The Acorns package includes several Laravel Artisan commands. You can find a current list here.
docker-compose run --rm cli wp acorn [artisan:command]Migrations can be created just like a default Laravel application.
docker-compose run --rm cli wp acorn make:migration create_this_table
docker-compose run --rm cli wp acorn migrateNOTE: Running migrate:fresh will drop all database tables, including your WordPress core tables. You may run the install script to reinstall WordPress and recreate all the database tables while maintaining your app's migrations.
Because the WordPress plugin operates in a different namespace than standard Laravel convention, you will need to pass the seeder class to the db:seed command so that the container will resolve the correct class.
docker-compose run --rm cli wp acorn db:seed --class=WordpressPluginTemplate\\Database\\Seeders\\DatabaseSeederYou can load and set environment variables using a .env file located in the src directory. Rename .env.example to .env to get started. The file will be automatically loaded by the application.
Any environment variable files by default will be excluded from your package. Make sure to set default values or modify scripts/package.sh to include *.env files when packaging.
WordPress' plugins sometimes encounter dependency namespace issues. To tackle this, it's advisable to prefix dependency namespaces with your own.
Note: Remember to compile your assets for production.
Use PHP-Scoper for this task. Install PHP-Scoper PHAR via Phive:
phive install humbug/php-scoper --force-accept-unsignedRun PHP-Scoper to prefix dependency namespaces and export the plugin files to the build folder.
composer prefixNext, dump the Composer autoloader so everything works as expected.
composer dump-autoload --working-dir build --classmap-authoritativeAfterward, package the plugin for distribution:
npm run packageRun the PHP linter. This will lint all files in the src directory. The linter uses Laravel Pint. The config can be edited from pint.json.
composer lintRun static analysis. This will analyze yourplugin.php and everything in src/app/... using PHPStan. The config can be edited from phpstan.neon.
composer test:typesRun the JS linter and format the code. The linter uses ESLint and the config can be edited from .eslintrc.cjs. The code formatter uses Prettier and the config can be edited from .prettierrc .
npm run lint
npm run format