Skip to main content

Project Structure

Stay Organised

Project Structure

Let's get acquainted with the default setup.

Preface

When you set up a project with composer create-project then you would have an app as shown below.

note

The given example below is for a theme. If you are making a plugin then you would have plugin.php instead of functions.php and you would be missing certain theme specific files and directories.

The default structure

Here is a complete example for a theme:

Project Structure Example
app                 # The directory to PSR-4 autoload. All your PHP classes goes in here somewhere
Hooks # All Hookable classes should be here
...
Controllers # Controllers for handling routes
...
Providers # Providers for registration and booting parts of the application
...
bootstrap
app.php # The application class is configured and created here
cache
config.php # The full config object get stored here when config is cached
packages.php # This file keeps track of installed packages
services.php # This file keeps track of installed services
block.php # The full list of blocks to register when blocks are cached
hook.php # The full list of hooks to load and boot when hooks are cached
route.php # The full list of routes to load and register when routes are cached
...
config # Config files for the application
app.php # Basic app conf. with providers
hook.php # Hooks. Where are they and what is their namespace?
wordpress.php # Misc. WordPress conf.
database
migrations # Migrations for managing DB tables
...
public
build
blocks # Register all blocks here by locating block.json files
...
css
...
js
...
images
logo.png
resources
blocks
myBlock
block.json
...
js
main.js
css
main.scss
views # Blade views
view.blade.php
routes # Routes for custom URLs
web.php
storage # A place for varios files that should not be public
framework # Framework specific storage
views # Compiled views are kept here
logs
...
.env.example # .env files must be located root level.
functions.php # Or plugin.php if app is a plugin
style.css