Files structure
Let's take a look at how are directories organized in a typical Cherrycake App setup, and the file naming conventions.
/
/src
/config
/patterns
/public
The root of your Cherrycake App directory. Can be placed anywhere in your server, a usual choice would be
/var/www/AppName
In its most basic form, it contains at least one important file:
- composer.json
- Cherrycake uses composer to manage dependencies. Modify this file to add your own dependencies if needed. To make your Cherrycake application work, the dependency
tin-cat/cherrycake-engine
is required.
/src/<ModuleName>/<ModuleName>.php
/src/<ClassName>.php
namespace CherrycakeApp\Home;
class Home extends \Cherrycake\Module {
[...]
}
Must be saved in a file here:
/src/Home/Home.php
And the following class:
namespace CherrycakeApp;
class User extends \Cherrycake\Item {
[...]
}
Must be saved in a file here:
/src/User.php
Contains the configuration files for your modules, if they need one. The syntax of this files is:
/config/<ModuleName>.config.php
For example, the configuration file for the module Home must be saved in a file here:
/config/Home.config.php
This is the directory that gets exposed publicly by an HTTP server like NGINX. It must have at least an
index.php
file to load the Cherrycake engine and attend requests.Check out the Getting started section to learn how to build this index file, or use the readily provided with the Skeleton or Docker methods.
There are some other non-required files and directories in a typical Cherrycake app, you'll find some of them there if you create your Cherrycake App using a boilerplate like the Cherrycake Skeleton.
/
/usr
/errors
/install
/vendor
If you've used the Cherrycake Skeleton to start your app, you'll also find this files in your app's root directory:
- cherrycake
- An executable script that allows you to perform a cli call to the Cherrycake application from the server command line.
- LICENSE_Cherrycake
- This contains the license disclaimer for the Cherrycake engine, please keep this file untouched in all your Cherrycake projects.
- cli.php
- A PHP script to launch a cli request to the Cherrycake application. This PHP file is used by the
cherrycake
script.
- load.php
- A convenience loader for the Cherrycake engine, used by any other scripts that need to run the Cherrycake engine, like
cli.php
, orpublic/index.php
Usually, this directory is used to store files uploaded by the users of an app. For example: If your app allows your users to upload their profile images, this is where you could be saving them using the Image core class.
Some Cherrycake modules make use of the database. This directory contains the SQL files needed to create the database tables needed for those Cherrycake modules.
For example, if you plan to use the Session module to manage your web app user sessions, you'll need to create the
cherrycake_session
table in your database by using the script session.sql
you'll find in this directory.This is the usual directory managed by Composer to hold all the dependency libraries, including the Cherrycake engine itself.
Last modified 1yr ago