yidemir / mikro
Micro approach to traditional
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-pdo: *
- ext-readline: *
Requires (Dev)
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.0
- 1.x-dev
- 1.6.0
- 1.5.0
- 1.4.7
- 1.4.3
- 1.4.0
- 1.3.0
- 1.1.10
- 1.1.5
- 1.1.4
- 1.1.2
- 1.1.0
- 1.0.1
- 1.0.0
- 0.x-dev
- 0.6.10
- 0.6.0
- 0.5.95
- 0.5.9
- 0.5.8
- 0.5.7
- 0.5.6
- v0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.3.8
- 0.3.0
- 0.2.16
- 0.2.14
- 0.2.12
- 0.2.10
- 0.2.8
- 0.2.6
- 0.2.4
- 0.2.2
- 0.2.0
- 0.0.6
- 0.0.4
- 0.0.2
- dev-big-update
- dev-view-template-component
- dev-table-component
This package is auto-updated.
Last update: 2024-10-29 05:16:51 UTC
README
Project in development. Do not use (yet)
mikro - micro approach to traditional
This project is a tool developed to solve some tasks and requests with simple methods, rather than a framework.
I tried to take this project, which I started as a hobby, one step further. There have been fundamental changes compared to the previous version.
Available packages:
- Cache - It is a simple caching structure.
- Config - It is a simple config structure with setter and getter.
- Console - Executes a callback according to the parameter from the command line.
- Container - A simple service container.
- Crypt - It encrypts and decrypts strings with OpenSSL.
- DB - It simplifies your CRUD operations with a PDO instance.
- Event - A simple event listener and emitter.
- Helper - String and array helpers and more
- Jwt - A simple JSON web token authentication structure.
- Locale - Multi-language/localization structure
- Logger - Basic logging
- Request - An easy way to access PHP global request variables.
- Response - Sends data/response to the client.
- Router - An ultra-simple router with grouping and middleware support.
- Validator - A simple data validation library.
- View - A view renderer with block and template support.
Installation
You can install the package via composer:
composer require yidemir/mikro
Usage
Routing
Router\get('/', fn() => Response\view('home'));
Router\group('/admin', fn() => [ Router\get('/', 'DashboardController::index'), Router\resource('/posts', PostController::class), Router\get('/service/status', fn() => Response\json(['status' => true], 200) ], ['AdminMiddleware::handle']); Router\files('/', __DIR__ . '/sync-directory');
Router\error(fn() => Response\html('Default 404 error', 404));
Database
$products = DB\query('select * from products order by id desc')->fetchAll(); $product = DB\query('select * from products where id=?', [$id])->fetch(); DB\insert('products', ['name' => $name, 'description' => $description]); $id = DB\last_insert_id(); DB\update('products', ['name' => $newName], 'where id=?', [$id]); DB\delete('products', 'where id=?', [$id]);
View and Templates
@View\set('title', 'Page title!'); @View\start('content'); <p>Secure print: @=$message; or unsecure print @echo $message;</p> @View\stop(); @View\start('scripts'); <script src="app.js"></script> @View\push(); @echo View\render('layout');
<!-- layout.php --> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>@View\get('title', 'Hey!');</title> </head> <body> @View\get('content'); @View\get('scripts'); </body> </html>
All methods and constants are documented at the source. The general documentation will be published soon.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email demiriy@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.