2017 © Pedro Peláez
 

library atl-framework

The Atl Framework.

image

atl/atl-framework

The Atl Framework.

  • Friday, March 23, 2018
  • by leeit1992
  • Repository
  • 1 Watchers
  • 0 Stars
  • 103 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

atl-framework

Framework MVC for team, (*1)

Get Started

Composer Download., (*2)

``` bash $ composer install, (*3)


## Load view ```php View('layout/header')

Use Route

Main index, (*4)

``` php $route->get('/','MainController@index');, (*5)


Route Get ``` php $route->get('/id/{id}', 'MainController@checkRouteGet');

Route Post, (*6)

``` php $route->post('/validate','MainController@checkRoutePost');, (*7)


Route validate int ``` php $route->get('/id/{id}', 'MainController@checkRoutePost', array('page' => '\d+'));

Validation Form;

Exemple detail., (*8)

``` php, (*9)

use Atl\Validation\Validation; $validator = new Validation;, (*10)

$validator->add( array(, (*11)

    // the key is in the form [field]:[label]
    'name:Name' => 'required',

    // you can have multiple rules for the same field
    'email:Your email' => 'required | email',

    // validators can have options
    'message:Your message' => 'required | minlength(10)',

    // and you can overwrite the default error message
    'phone:Phone' => 'regex(/your_regex_here/)(This field must be a valid US phone number)'
)

);, (*12)

if ($validator->validate($_POST)) {, (*13)

// send notifications to stakeholders
// save the form data to a database

} else {, (*14)

// send the error messages to the view
$view->set('errors', $validator->getMessages();

}, (*15)


## Session; Handle session. ``` php // Config file config/app.php 'session' => array( 'status' => true, 'storage' => ''), // Use code base Session()->set('name','Test Session'); echo Session()->get('name'); // Session flash Session()->getFlashBag()->set('name', 'Test'); var_dump(Session()->getFlashBag()->has('name')); var_dump(Session()->getFlashBag()->get('name'));

Redirect;

Handle redirect url., (*16)

``` php, (*17)

redirect( url('exemple/id/1') );, (*18)

## __ ;

``` php


Use pagination

use Atl\Pagination\Pagination;

$ofset                = 10; // Result query row number.
$config['pageStart']  = $page; // Number of page.
$config['ofset']      = $ofset; 
$config['totalRow']  = 50; // Number of count total row.
$config['baseUrl']   = url('/page/'); // Url base of pagination.

$pagination          = new Pagination($config);

echo $pagination->link( $config );

Use Model

Use model static, (*19)

``` php DB()->insert("account", [ "user_name" => "foo", "email" => "foo@bar.com" ]);, (*20)

DB()->update("account", [ "user_name" => "foo", "email" => "foo@bar.com" ],[ "id" => 1 ]);, (*21)

DB()->select("account", [ "user_name", "email" ], [ "user_id[>]" => 100 ]);, (*22)

DB()->select("account", "user_name", [ "email" => "foo@bar.com" ]); // WHERE email = 'foo@bar.com', (*23)

DB()->select("account", "user_name", [ "user_id" => 200 ]); // WHERE user_id = 200, (*24)

DB()->select("account", "user_name", [ "user_id[>]" => 200 ]); // WHERE user_id > 200, (*25)

DB()->select("account", "user_name", [ "user_id[>=]" => 200 ]); // WHERE user_id >= 200, (*26)

DB()->select("account", "user_name", [ "user_id[!]" => 200 ]); // WHERE user_id != 200, (*27)

DB()->select("account", "user_name", [ "age[<>]" => [200, 500] ]); // WHERE age BETWEEN 200 AND 500, (*28)

DB()->select("account", "user_name", [ "age[><]" => [200, 500] ]); // WHERE age NOT BETWEEN 200 AND 500, (*29)

// [><] and [<>] is also available for datetime DB()->select("account", "user_name", [ "birthday[><]" => [date("Y-m-d", mktime(0, 0, 0, 1, 1, 2015)), date("Y-m-d")] ]); //WHERE "create_date" BETWEEN '2015-01-01' AND '2015-05-01' (now), (*30)

// You can use not only single string or number value, but also array DB()->select("account", "user_name", [ "OR" => [ "user_id" => [2, 123, 234, 54], "email" => ["foo@bar.com", "cat@dog.com", "admin@medoo.in"] ] ]); // WHERE // user_id IN (2,123,234,54) OR // email IN ('foo@bar.com','cat@dog.com','admin@medoo.in'), (*31)

// [Negative condition] DB()->select("account", "user_name", [ "AND" => [ "user_name[!]" => "foo", "user_id[!]" => 1024, "email[!]" => ["foo@bar.com", "cat@dog.com", "admin@medoo.in"], "city[!]" => null, "promoted[!]" => true ] ]); // WHERE // user_name != 'foo' AND // user_id != 1024 AND // email NOT IN ('foo@bar.com','cat@dog.com','admin@medoo.in') AND // city IS NOT NULL // promoted != 1, (*32)

// Or fetched from select() or get() function DB()->select("account", "user_name", [ "user_id" => DB()->select("post", "user_id", ["comments[>]" => 40]) ]); // WHERE user_id IN (2, 51, 321, 3431), (*33)

```, (*34)

The Versions

23/03 2018

dev-master

9999999-dev

The Atl Framework.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Le Trung Ha

23/06 2017

1.0.x-dev

1.0.9999999.9999999-dev

The Atl Framework.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Le Trung Ha