Bare Framework is a lightweight and minimalistic PHP framework designed for simplicity and speed. It provides essential features like routing, templating with Plates, and database handling with Eloquent ORM.
- Simple routing system using
League\Route - Lightweight templating with
Plates - Eloquent ORM for database interactions
- Dependency Injection with
League\Container .envsupport for configuration- PSR-7 & PSR-15 middleware compatibility
- Asset management for CSS, JS, and images
git clone https://github.com/berramou/bare.git
cd bareLando is recommended for an easy development environment setup.
Check the Lando documentation for installation instructions.
lando composer installCopy .env.example to .env and update the database credentials as needed.
lando startRoutes are defined in the /routes directory (e.g., web.php, api.php, etc.).
Example of routes/web.php:
use Bare\Routing\RouteBuilder;
use App\Controllers\HomeController;
return function ($router, $container) {
// Home page route
$router->get('/', [$container->get(HomeController::class), 'index']);
};Create a new controller in the app/Controllers directory.
<?php
namespace App\Controllers;
use Laminas\Diactoros\Response\HtmlResponse;
use Bare\Core\BaseController;
use Psr\Http\Message\ServerRequestInterface;
class FormController extends BaseController
{
public function showForm(): HtmlResponse
{
// Instantiate the form class.
$form = new Form();
// Add fields to the form.
$form->addField('name', 'text', ['label' => 'Name', 'required' => true])
->addField('email', 'email', ['label' => 'Email', 'required' => true])
->addField('submit', 'submit', ['label' => 'Submit']);
// Render the form view.
return $this->view->render('form/some-form', ['form' => $form]);
}
}Add a new route in the routes/web.php file.
return function ($router, $container) {
// Form example route
$router->get('/form/example', [$container->get(FormController::class), 'showForm']);
};Create the form template in resources/templates/form/some-form.php.
<form method="POST" action="/form/example">
<?= $form->render() ?>
</form>- Run
lando startto start the development server. - Open your browser and visit
https://bare.lndo.site.
For additional details, check the src folder for controllers, models, and services.
Happy coding! 🚀