Project structure
We'll now take a look at standard project structure for plugins and themes.
Plugin structure
If you open up a Forme plugin repo directory in your editor of choice, the top level will look something like this:
.
├── .editorconfig
├── .gitignore
├── app/
├── assets/
├── cliff.toml
├── composer.json
├── conventional.json
├── forme.env.example
├── helpers/
├── index.php
├── languages/
├── captainhook.json
├── package-lock.json
├── package.json
├── phpstan.neon.example
├── readme.md
├── hello-world-plugin.php
├── routes/
├── scripts
├── uninstall.php
├── views/
└── webpack.config.js
Some of the elements will look famliar to you if you've done any standard WordPress plugin development, but some details that jump out are the app
, views
and assets
directories and the composer.json
. This isn't your usual WordPress joint.
This is a fairly typical modern php directory structure:
app
is where all your classes and most of your business logic live (also calledsrc
in some frameworks)assets
is for frontend files, e.g js, css/scss and imageshelpers
is for global helper functionsroutes
is where you define and declare your custom routesviews
is where your view templates go. Forme supports Blade, Twig, Plates, and "legacy" Plates 4.
TIP
We're not talking about "templates" in the WordPress sense here (i.e. 1990s era mushed up php and html spaghetti code hell), we mean modern php view templating engines. Forme supports Blade, Twig Plates, and "legacy" Plates 4.
Theme structure
There's a similar thing going on with themes. Again there's an app
, views
and assets
directory alongside composer.json
and some of the standard WordPress files.
.
├── .editorconfig
├── .gitignore
├── app/
├── assets/
├── captainhook.json
├── cliff.toml
├── composer.json
├── conventional.json
├── forme.env.example
├── functions.php
├── helpers/
├── index.php
├── package-lock.json
├── package.json
├── page.php
├── phpstan.neon.example
├── readme.md
├── routes/
├── scripts
├── screenshot.png
├── single.php
├── style.css
├── views/
└── webpack.config.js