1. Go to this page and download the library: Download yurigabriel/myframework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Model;
use Framework\Libs\Annotations\DataBase\Collumn;
use Framework\Libs\Annotations\DataBase\Model;
use Framework\Libs\Annotations\DataBase\PrimaryKey;
#[Model("product")]
class Product {
#[PrimaryKey]
#[Collumn]
public $id;
#[Collumn]
public $name;
#[Collumn]
public $price;
}
namespace App\Repository;
use App\Model\Product;
use Framework\Libs\DataBase\Repository;
class ProductRepository extends Repository {
public function __construct() {
parent::__construct(Product::class);
}
}
namespace App\Controller;
use App\Repository\ProductRepository;
use Framework\Libs\Annotations\Controller;
use Framework\Libs\Annotations\Instantiate;
use Framework\Libs\Annotations\Mapping;
use Framework\Libs\Engine\Render;
#[Controller]
class ProductController {
#[Instantiate]
public ProductRepository $repo;
#[Mapping('/products')]
public function index() {
$data = $this->repo->select(['*'])->run();
Render::render('products/index');
}
}
namespace App\Middleware;
use Framework\Libs\Annotations\Middleware;
use Framework\Libs\Http\Interceptable;
#[Middleware]
class AdminOnly implements Interceptable {
public function rule(): bool {
// checar autorização
return isset($_SESSION['user']) && $_SESSION['user']['role'] === 'admin';
}
}
bash
php command run
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.