Skip to content

Code-Ark 2.0 is an updated version of Code-Ark framework. Code-Ark 2.0 is composer based, elegant and an easy to use and understand PHP Framework. It has almost every modern aspects of an MVC-R framework, for building small to medium size websites and web apps.

Notifications You must be signed in to change notification settings

code-architect/Code-Ark-2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code-Ark 2.0

Code-Ark by codearchitect.in

Features

  • 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

Configure

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

Router

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 '@'.

************************************************************************************************************************

Composer and Dependency

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'])
));
Here on the first line we are binding the dependency. In the bind(), 'config' is the label we are giving. Same goes for the next line database is just a label, and next we are creating a new QueryBuilder.

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.

************************************************************************************************************************

Views

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";
}

Models

Change Database information in the config.php file.

Exception Handler

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.


About

Code-Ark 2.0 is an updated version of Code-Ark framework. Code-Ark 2.0 is composer based, elegant and an easy to use and understand PHP Framework. It has almost every modern aspects of an MVC-R framework, for building small to medium size websites and web apps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published