1. Go to this page and download the library: Download mapathe/core 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/ */
mapathe / core example snippets
$container = Container::getInstance();
// Lier une classe
$container->bind(Interface::class, Implementation::class);
// Singleton
$container->singleton(Service::class);
// Résoudre
$service = $container->resolve(Service::class);
// Initialiser l'application
App::initialize();
// Récupérer un service
$controller = App::get('CitoyenController');
$service = App::get(\App\Service\CitoyenService::class);
class CitoyenController extends AbstractController
{
public function index() {
$data = ['users' => []];
$this->renderJson($data, "success", 200, "Liste récupérée");
}
}
class User extends AbstractEntity
{
public static function toObject(array $data): static {
// Conversion array vers objet
}
public function toArray(): array {
// Conversion objet vers array
}
}
class UserRepository extends AbstractRepository
{
public function findAll() {
$stmt = $this->pdo->query("SELECT * FROM users");
return $stmt->fetchAll();
}
}
// Structure du projet
/src
/core # Classes du framework
/config
services.yml # Configuration des services
/routes
route.web.php # Définition des routes
// Bootstrap
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.