Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

4GeeksAcademy/wordpress-hello

Repository files navigation

🚨 WARNING 🚨 This repository its not maintained anymore, we don't recomend using anymore.

WordPress Boilerplate for Professional Development

Headless WordPress Boilerplate to start a new project in WordPress in just 2 minutes, with MVC API generation like any other modern framework like Express, Flask or Slim PHP.

Video Tutorial about this boilerplate

Features

  1. Dockerfile for a working LAMP environment with PHP 7.2.19 and PHPMyAdmin.
  2. WordPress CLI (WP CLI).
  3. Support for .env file to easily publish into production with environment variables.
  4. One commend install with install.sh bash script.
  5. It comes with a WordPress Plugin ideal for using headless WordPress API working with typical MVC (Model View Controller) pattern.
  6. Composer integration to install plugins or PHP packages via package manager.
If used with Gitpod
  1. Easy access to apache and PHP error log with commcommand: gp open /var/log/apache2/error.log

Installation Procedure

1) Start by installing the boilerplate

There are 3 ways of installing this:

  1. Use git to clone re repo
$ git clone git@github.com:4GeeksAcademy/wordpress-hello.git
  1. Just click here to use it with gitpod.

2) Install the composer packages

$ composer install

3) Create a .env file with your database and site information (on the workspace root) and run the run the installator

$ bash install.sh

You are done! Start working!

Check your website, you are going to see a "Hello Rigoberto" message, you can login into the dashboard with your c9 username and the password you specified.

- Adding API enpoints

This boilerplate comes with a sample API andpoint already, all api enpoints can be added into the setup_api.php file like this:

// adding a GET /courses endpoint handled by the function getDraftCourses in the SampleController.php file
$api->get([ 'path' => '/courses', 'controller' => 'SampleController:getDraftCourses' ]);

Here is more info on how to create the API endpoints.

- Adding Entities (Post Types)

All the Post Types configuration is done in the setup_types.php file like this:

// adding Post Type "Course" handled by the file Course.php
$typeManager->newType(['type' => 'course', 'class' => 'Course'])->register();

Here is more info on how to create the post-types.