PhpSlides follows the MVC (Model-View-Controller) architecture, where each folder and file serves a specific purpose. Below is the default project directory structure:
Project Directory
βββ app/
β βββ Controller/
β βββ Forgery/
β βββ Http/
β β βββ Api/
β β βββ Controller/
βββ src/
β βββ configs/
β β βββ cors.php
β β βββ guards.php
β β βββ jwt.php
β βββ resources/
β β βββ views/
β β βββ App.psl
β βββ routes/
β β βββ api.php
β β βββ web.php
β β βββ render.php
βββ vendor/
βββ .env
βββ .htaccess
βββ config.json
This structure includes critical directories for the logic, configuration, routes, and resources required to build your PhpSlides application.
The app directory contains subdirectories where the main logic code is written.
The Forgery directory contains database structure files, which define the database schema.
You can:
- Create these files manually, or
- Use the
phpslidescommand.
View the Database System Guide for more details.
This directory contains HTTP-related logic, including API endpoints and guards.
-
app/Http/ControllerThis directory consists of Controller classes, which are used in routing.
To create a new Controller class:- You can create it manually and write the default code.
- Or use the
phpslidescommand, which will automatically create the class with the default code.
Command to create a new Controller:
phpslides make:controller ClassName
- Replace
ClassNamewith the desired name of the Controller. - All generated Controller classes will end with
Controller(e.g.,HomeController).
-
app/Http/Api:
This directory consists of API Controller classes used in API routes.
To create an API endpoint:phpslides make:api-controller User
- Replace
Userwith the endpoint name. - The file and class name must end with
Endpoint(e.g.,UserEndpoint).
The command automatically creates the endpoint in the
app/Http/Apidirectory with a template code similar to that of a regular Controller. - Replace
-
app/Http/Guards:
This directory contains authentication logic for protecting routes. Guards can be created manually or using the command:phpslides make:guard AdminGuard
- Replace
AdminGuardwith the desired guard name.
- Replace
The src directory is responsible for handling configuration, resources, and routes.
This directory contains configuration files for PhpSlides, including settings for:
- CORS
- JWT
- Guards
This directory is used for route registration.
- The main file for registering routes is
render.php. - Sub-files include
web.phpfor web routes andapi.phpfor API routes.
You can register all routes inside render.php and call the render function.
This directory contains files that are rendered on the client side.
- It includes the
viewsdirectory, where all view files must be stored. - Other subdirectories like
assetscan also be added for additional resources.
phpslides make:controller ClassName- Creates a new Controller in
app/Http/Controller.
phpslides make:api-controller EndpointName- Creates a new API endpoint in
app/Http/Api.
phpslides make:guard GuardName- Creates an authentication guard in
app/Guards.