bigtunacan / thiccnr

PHP Framework based on Slim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project Structure

Thiccnr 3 is built on Slim 3, but tries to follow a structured MVC pattern along with the Front Controller pattern to ensure better security.

Front Controller The front controller should reside in public/index.php and this should be the only file directly served by Apache.

The front controller public/index.php sets up autoloading and calls bootstrap/app.php which should handle all shared setup such as

  • Slim app configurations
    • Template initialization (Twig/other)
  • Database connections setup
  • Loading of route files
  • etc...

Views Views/Layouts/Templates reside in resources/views

Routes

  • Directory routes/
  • api.php is for JSON endpoints intended to be called via AJAX requests
  • web.php is for endpoints that should server-side render a webpage
  • additional route files (for example crons.php) should be added to bootstrap/app.php

App

  • The bulk of the application logic resides in the app/ sub-directory.
  • Directories
    • Controllers
      • Controllers should logically organize code executed directly from routes.
      • Routes can call a Controller method in a manner such as
      • $app->get('/users', UserController::class . ':index');
        • Where :inde represents a function on the UserController class
    • Handlers
      • Custom exception handling
    • Middleware
      • Any custom Slim Middleware classes go here
    • Models
      • Organize database logic here
    • Validation
      • Custom validation classes reside in Validation/Rules
      • Corresponding exceptions reside in Validation/Exceptions
      • The Respect/Validation package is used for validations

Helpers helpers/helpers.php holds global helper functions

If helpers.php starts growing too large then it can be split up into separate logical files and required in bootstrap/app.php

If helpers.php starts growing too large you may also consider if you are doing things wrong and look at a better means of refactoring.

About

PHP Framework based on Slim


Languages

Language:PHP 71.7%Language:HTML 28.3%