nsamsdev / codebasephp
Very Basic PHP VCMM Framework
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:framework
Requires
- php: >=7.0.0
- h4cc/wkhtmltopdf-amd64: 0.12.3
- illuminate/database: v5.2.31
- imagine/imagine: v0.6.3
- mikehaertl/phpwkhtmltopdf: 2.2.1
- monolog/monolog: 1.17.2
- nategood/httpful: 0.2.20
- php-ffmpeg/php-ffmpeg: 0.9.2
- phpunit/phpunit: 6.0.9
- sendgrid/sendgrid: 4.0.4
- smarty/smarty: v3.1.29
- sonata-project/cache: 1.0.7
This package is auto-updated.
Last update: 2024-11-10 02:08:24 UTC
README
Controllers
<?php use CodeBase\Controller; use CodeBase\HttpRequester; class Home extends Controller { /** a must have contructor on all controller to access parent features */ public function __construct($baseClasses) { parent::__construct($baseClasses, 'Home'); } /** all methods that you wish to have a param passed to via browser url * args must have only one params which is an arrray of all the parameters */ public function index($params) { /** loads \CodeBase\Models\User */ $user = $this->loadModel('User'); } }
Routes
/* Routes are defined in app/routes.php, Add method accespts 5 params, 3 mandatory and 2 optional first param is the url route, second param is execution method Class@MethodName, third param is the allowed request method fourth param/optional is boolean, true or false to lock acess to this route based on session set fifth param/optional is the session key name that must be set to access this route if you pass 4th param top the add method you must also pass the 5th param */ <?php /** @file app/routes.php */ use CodeBase\Router; if (!defined('CODEBASE')) { die('Direct Access Not Allowed'); } Router::add('/', 'Home@index', ['GET']); Router::add('account', 'Home@Profile', ['GET'], true, 'userSessionId');
Models (Eloqouent ORM)
<?php namespace CodeBase\Models; class User extends \CodeBase\Model { /** @var array */ protected $fillable = [ 'name', 'age' ]; /** @var bool */ public $timestamps = false; public function addUser($name, $age) { User::create([ 'name' => $name, 'age' => $age ]); } }
Models (Standard PDO)
<?php namespace CodeBase\Models; class User extends \CodeBase\BASIC_MODEL { public function __construct() { parent::__construct(); } }
Views
From within a controller method call:
/** .tpl is automatically added */ $this->view->render('homepage', $dataArrayToPass);
Application Structure
- app
- controllers
- models
- views
- cache
- compile
- config
- templates
- managers
- routes.php
Helpers (Libraries)
- Managers
- PdfCreator
- SessionManager
- ErrorHandler
- CustomEmailer/PHPMailert
- HttpRequester
- Hooks