vladidas / mvc
The Micro-Framework which created for building speeder and usability applications.
dev-master
2018-11-01 17:15 UTC
Requires
- php: >=5.5.9
- mongodb/mongodb: 1.1.*
This package is auto-updated.
Last update: 2025-03-29 00:40:58 UTC
README
Faster, responsible and usability MVC micro-framework.
Official Documentation
TODO... His will been later :)
Install:
composer require vladidas/mvc @dev
Using:
Routing:
file:
HTTP\router.php
// Languages.
Route::lang(['ua', 'end', 'ru']);
// GET-rquests.
Route::get('/', 'client/IndexController@index');
Route::get('/', 'client/IndexController@index', ['name' => 'home']);
// POST-requests.
Route::post('/', 'client/IndexController@index');
Route::post('/', 'client/IndexController@index', ['name' => 'home']);
// Error exceptions.
Route::error('404', 'errors/ErrorController@error404');
Models:
folder:
App\Models
There create all models, whict has been using in application.
Configs:
class Users extends Models {
public $table_name = 'clients';
public $connection = 'mysql';
//
}
- #### Relationships:
- hasOne:
public function role() {
return $this->hasOne(Roles::class, 'id', 'manager_id');
}
// or
public function role() {
return $this->hasOne('App\Models\Roles', 'id', 'manager_id')->orderBy('id', 'desc');
}
// or
public function role() {
return $this->hasOne(Roles::class, 'id', 'manager_id')->select('id', 'name')->where('id', 1);
}
- hasMany:
public function users() {
return $this->hasMany(Users::class, 'id', 'manager_id');
}
// or
public function users() {
return $this->hasMany('App\Models\Users', 'id', 'manager_id')->orderBy('id', 'desc');
}
// or
public function users() {
return $this->hasMany(Users::class, 'id', 'manager_id')->select('id', 'name')->where('id', '>', 1);
}
2. #### Controllers:
___folder: `App\Controllers`___
<?php
namespace App\Controllers\client;
use App\Controllers\Controller; use Vendor\Http\Request; use App\Models\Users;
class IndexController extends Controller {
/** Show all users. */
public function index()
{
$users = Users::with('role')
->where('id', '>', 1)
->orderBy('id', 'desc')
->get();
return views('users/index', compact($users));
}
/** Show user. */
public function show(Request $request)
{
$users = Users::with('role')
->select('id', 'name')
->where('id', '>', $request->get->arguments->id)
->get();
return views('users/show', [
'users' => $users
]);
}
}
2. #### Views:
___folder: `App\Views`___
<?= $title ?>