Template for new WordPress projects
JavaScript PHP HTML CSS Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
build
etc
src
tests
webroot Use correct .env parameter for debug display (task #6668) Jul 24, 2018
.editorconfig
.env.example
.gitattributes Added .gitattributes with some defaults Jan 27, 2016
.gitignore
.stickler.yml
.travis.yml
LICENSE
README.md
bitbucket-pipelines.yml
composer.json
docker-compose.yml
phpcs.xml.dist
phpunit.xml.dist

README.md

project-template-wordpress

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

About

This is a template for the new project using WordPress. It is heavily based on the work done in project-template.

Developed by Qobo, used in Qobrix.

Install

When starting a new WordPress project, do the following:

composer create-project qobo/project-template-wordpress example.com
cd example.com
git init
git add .
git commit -m "Initial commit"
# Finalize the setup
composer install
./bin/build app:install DB_NAME=wordpress,PROJECT_NAME="My Project",PROJECT_VERSION="v1.0.0"

DB_NAME, the name of the database to use, is the only setting which is required. The rest is being figured out automatically, but you can easily adjust them. Have a look at .env.example file for defaults.

Update

When you want to update your project with the latest and greatest project-template-wordpress, do the following:

cd exmample.com
git pull https://github.com/QoboLtd/project-template-wordpress

Usage

Quick

Now that you have the project template installed, check that it works before you start working on your changes. Fire up the PHP web server:

./bin/phpserv

Or run it on the alternative port:

./bin/phpserv -S localhost:9000

In your browser navigate to http://localhost:8000. You should see the standard phpinfo() page. If you do, all parts are in place.

Now you can develop your PHP project as per usual, but with the following advantages:

  • Support for PHP built-in web server
  • Per-environment configuration using .env file, which is ignored by git
  • Powerful build system (Robo) integrated
  • Composer integrated with vendor/ folder added to .gitignore .
  • PHPUnit integrated with tests/ folder and example unit tests.
  • Sensible defaults for best practices - favicon.ico, robots.txt, MySQL dump, Nginx configuration, GPL, etc.

For example, you can easily automate the build process of your application by modifying the included Robo files in build/ folder. Run the following command to examine available targets:

./bin/build

As you can see, there are already some placeholders for your application's build process. By default, it is suggested that you have these:

  • app:install - for installation process of your application,
  • app:update - for the update process of the already installed application, and
  • app:remove - for the application removal process and cleanup.

You can, of course, add your own, remove these, or change them any way you want. Have a look at Robo documentation for more information on how to use these targets and pass runtime configuration parameters.

Test

PHPUnit

project-template-wordpress brings quite a bit of setup for testing your projects. The first part of this setup is PHPUnit. To try it out, runt the following command (don't worry if it fails, we'll get to it shortly):

./vendor/bin/phpunit

If it didn't work for you, here are some of the things to try:

  • If phpunit command wasn't found, try composer install and then run the command again. Chances are phpunit was removed during the app:install, which runs composer with --no-dev parameter.
  • If you had some other issue, please let us know.

Travis CI

Continious Integration is a tool that helps to run your tests whenever you do any changes on your code base (commit, merge, etc). There are many tools that you can use, but project-template-wordpress provides an example integration with Travis CI.

Have a look at .travis.yml file, which describes the environment matrix, project installation steps and ways to run the test suite. For your real project, based on project-template-wordpress, you'd probably want to remove the example tests from the file.

Examples

project-template-wordpress provides a few examples of how to write and organize unit tests. Have a look in the tests/ folder. Now you have NO EXCUSE for not testing your applications!

Configurations

Plugin - Compress PNG for WP (Using TinyPNG API)

This plugin requires an API key from TinyPNG. You can set your key in .env.example file using parameter TINYPNG_API_KEY. A default valid API key has already been added to the template but due to a limited number of requests allowed per key, each project should be using its own key. You can get an API key at https://tinypng.com/developers (one key per email address).