-
Removed: Added Twig template and Twig rendered views
Added: There is a composer.json file so any templating engine can be added,don't have to depend on twig anymore. -
Removed: Error Log
Added: Now we throwing exception. You can catch that exception and generate a dedicated class to show errors in your way. -
Removed: HTTP status code based Error
-
Removed: Custom 404 and 500 error message display page for production level
-
Added: Namespaces.
-
PDO Database connection
-
Pretty URLs
-
Removed: PSR-1 Coding standards
Added: PSR-2 Coding standards -
Exception Handler and Error Handler Throwing Exceptions.
-
Development and Production Mode
-
New: Autoload Classes using composer
-
New: Registering Routes specifically for GET request and Post Request
The Code-Ark 2.0 is here!!! I have added and removed few features from the application. It's now more MVC base. It's now suitable for any small scale to medium scale projects.
Change the config.php to attach your database details. Thats the only change you have to do. I have an example application for learning purposes, modify it or remove it entirely, it's up to you. This framework follows the basic MVC-R (Model, View, Controller, Router) structure. And also it's very easy to understand. Create a database first the after installation connect the database with config.php
In the routes file declare the routes like $router->get('about', 'PagesController@about');
or
$router->post('about', 'PagesController@about');
Name of the route is 'about', the controller's name is PagesController, and the method responsible is 'about' method.
You must separate the controller and the method using '@'.
************************************************************************************************************************
Run the composer dump-autoload command to reload any new file. Can use this to add any needed dependency.
To add any dependency injection use this code in the bootstrap.php file to access it from anywhere in the application.
App::bind('config', require 'config.php');
App::bind('database', new QueryBuilder(
Connection::make( App::get('config')['database'])
));
In the controllers directory, inside the PagesController you will see,
public function home()
{
$articles = App::get('database')->selectAll('articals');
return view('index');
}
In here we are getting the dependency so we can use it {I know the spelling is wrong, it was intended}. The App::get will get the dependency according to the label.
************************************************************************************************************************
Your view files are located in the views folder, and css and js files are located in to public folder.
The view files must follow a naming pattern. index.view.php
If you want to change this style, navigate to bootstrap.php and change the view helper function
function view($name, $data)
{
extract($data);
return require "app/views/{$name}.view.php";
}
Change Database information in the config.php file.
In the config.php file, the optional error mode has been declared as PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
You can change it and can also catch the error to show a 404 page or 400 page error.
In the core/database/Connection.php, you will find a PDO error display method showPdoError(), out of the box.