- Pull project to your server with git or download
git clone https://github.com/emrancu/php-mvc-project.git
- Create a Database
- Open Project in browser and submit your database name, user & password in a form
- Then Done
- PSR-4
"psr-4": { "App\\": "app/", }
- Simple Routing System
$router->get('/', function($request) { $controller = new HomeController($request) ; return $controller->home(); });
$router->get('/', 'HomeController@home'); $router->get('/database-setup', 'DatabaseSetupController');
- Dependency Injection Container
namespace - App\System\Base\Container; DependencyContainer::instance()->call("HomeController@index"); DependencyContainer::instance()->call("HomeController", $parameters); // call __invoke method DependencyContainer::instance()->make(HomeController::class, $parameters); // get instance
EnvManager::createEnvFile($configData); // create db.env file in /config dir EnvManager::get('host') // get config
responseJson("Something went wrong", 422); redirect('/home'); sessionFlash('message', 'Successfully inserted'); view('person.create', compact('types') view('person.create',["types" => $types]) config('author.name') // get config data from /config/app.php url('home') // generate route url
$purchase = new Purchase(); $purchaseData = $purchase->getAll(); return view('index', compact('purchaseData')); or return view('index', ['purchaseData' => $purchaseData]);
// unset flush session function unsetFlashSession() { foreach ($_SESSION as $key => $value) { if (strpos($key, 'app_flash_') === 0) { unset ($_SESSION[$key]); } } }// set or get session function sessionFlash($name, $message = '') { if ($message) { $_SESSION["app_flash_" . $name] = $message; } else { return $_SESSION["app_flash_" . $name] ?? ''; } }
$check = Validator::execute($this->request, [ 'amount' => 'required|number', 'buyer' => 'required|noSpecialChar|limit:20,50', 'receipt_id' => 'required|letter', 'buyer_email' => 'required|email', 'note' => 'required|wordLimit:2,30', 'city' => 'required|letter', 'phone' => 'required|mobile', 'entry_by' => 'required|number' ]);if (!$check['status']) { return json($check, 419); }
Self Developed: Field Validator
Self Developed: webToast
The MIT License (MIT)
Developed with ❤ by AL EMRAN