Cherrycake
ExamplesGithub
version 2.x alpha
version 2.x alpha
  • Introduction
  • Status
  • Changelog
  • Migration
  • Architecture
    • Basics
    • Modules
    • Classes
    • Lifecycle
      • Deep lifecycle
    • Performance
    • Security
    • Patterns
      • Files structure
    • Items
    • Server requirements
  • Guide
    • Getting started
      • Skeleton start
      • Docker start
    • Modules guide
    • Classes guide
    • Actions guide
      • Complex actions
      • Variable path components
      • Accept GET or POST parameters
      • Getting the URL of an action
      • Cached actions
      • Brute force attacks
    • Patterns guide
      • Passing variables to a pattern
      • Nested patterns
      • Cached patterns
    • Cache guide
      • Time To Live
      • Using cache
      • Lists
      • Queues
      • Pools
    • Database guide
      • Basic queries
      • Prepared queries
      • Cached queries
      • Cache key naming
      • Removing queries from cache
    • Items guide
      • Item cache
      • Item lists
      • Items custom filters
      • Items custom ordering
      • Mixing filters and ordering
      • Items with relationships
      • Items cache
    • HtmlDocument guide
    • Css and Javascript guide
      • Modules injecting CSS and JavaScript
    • Session guide
    • Login guide
      • Creating a complete login workflow
    • Locale guide
      • Multilingual texts
      • Domain based site localization
    • Log guide
      • Loading Log events from the database
    • Stats guide
      • Stats events with additional dimensions
      • Loading Stats events from the database
    • Janitor guide
      • Janitor tasks configuration files
    • Command line interface
    • Debugging
  • Reference
    • Core modules
      • Actions
        • Actions methods
      • Browser
      • Cache
        • Cache methods
      • Css
        • Css methods
      • Database
      • Email
      • Errors
      • HtmlDocument
        • HtmlDocument methods
      • ItemAdmin
      • Janitor
        • Janitor methods
      • Javascript
        • Javascript methods
      • Locale
        • Locale methods
      • Log
        • Log methods
      • Login
        • Login methods
      • Output
        • Output methods
      • Patterns
        • Patterns methods
      • Security
        • Security methods
      • Session
        • Session methods
      • Stats
        • Stats methods
      • SystemLog
      • TableAdmin
      • Translation
      • Validate
    • Core classes
      • Action
        • Action methods
        • Action properties
      • AjaxResponseJson
      • BasicObject
        • BasicObject methods
      • CacheProvider
        • CacheProvider methods
      • Color
      • DatabaseProvider
        • DatabaseProvider methods
      • DatabaseResult
        • DatabaseResult methods
        • DatabaseResult properties
      • DatabaseRow
      • Engine
        • Engine methods
        • Engine properties
      • Gradient
      • Item
        • Item methods
        • Item properties
      • Items
        • Items methods
        • Items properties
      • Image
      • JanitorTask
        • JanitorTask methods
        • JanitorTask properties
      • LogEvent
        • LogEvent methods
        • LogEvent Properties
      • LogEvents
        • LogEvents methods
      • Module
        • Module methods
        • Module properties
      • Response
      • Request
        • Request methods
      • RequestParameter
        • RequestParameter methods
      • RequestPathComponent
        • RequestPathComponent methods
      • Result
      • StatsEvent
        • StatsEvent properties
      • StatsEvents
        • StatsEvents methods
      • SystemLogEvent
        • SystemLogEvent methods
        • SystemLogEvent properties
      • SystemLogEvents
        • SystemLogEvents methods
  • Code conventions
  • License
  • Extras
Powered by GitBook
On this page

Was this helpful?

  1. Architecture
  2. Patterns

Files structure

Let's take a look at how are directories organized in a typical Cherrycake App setup, and the file naming conventions.

PreviousPatternsNextItems

Last updated 3 years ago

Was this helpful?

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 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.

Contains your , each one in a subdirectory named in the syntax:

/src/<ModuleName>/<ModuleName>.php

Also contains your , each in one file named in the syntax:

/src/<ClassName>.php

It is recommended that modules follow the naming . For example, the following module:

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.

Other files and directories

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 .

If you've used the 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 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 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, or public/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 core class.

This directory holds the HTML files the shows to the browser when errors occur. You change this to a different directory by setting the patternNames key in the module configuration file.

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 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 to hold all the dependency libraries, including the Cherrycake engine itself.

Check the documentation for more information

This directory also holds the configuration files for .

Contains the HTML files to be used by the module. This directory can be set to anything else by changing the directory config key of the module.

Check out the section to learn how to build this index file, or use the readily provided with the or methods.

Janitor Tasks
Patterns
Patterns
Getting started
Skeleton
Docker
composer
modules
classes
conventions
Cherrycake Skeleton
Cherrycake Skeleton
cli
cli
Image
Errors
Errors
Session
Composer
Module config files