luthier framework
Version 0.1.1
تحذير: قيد التنمية!
Luthier Framework هو عمل متعدد الاستخدامات PHP Micro-Framework لبناء واجهات برمجة التطبيقات والمواقع الصغيرة بسرعة. عندما نقول "Micro" ، نعني حقًا micro: في الواقع ، لا يلزم سوى الملحن وملف .php واحد للبدء.
الحصول على إطار Luthier مع الملحن:
composer require luthier/framework
مثال أساسي:
<?php
# your_app/index.php
require ' vendor/autoload.php ' ;
$ app = new Luthier Framework ();
$ app -> get ( ' / ' , function (){
$ this -> response -> write ( " Hello world! " );
});
$ app -> group ( ' api ' , function (){
$ this -> get ( ' / ' , function (){
json_response ([ ' message ' => ' Welcome to Luthier Framework! ' ]);
});
$ this -> get ( ' about ' , function (){
json_response ([ ' version ' => Luthier Framework:: VERSION ]);
});
});
$ app -> run (); تحديد الطرق:
$ app -> get ( ' foo/ ' , function (){
// Default template engine (will search for /foo.php file)
view ( ' foo ' );
});
$ app -> post ( ' bar/ ' , function (){
view ( ' bar ' );
});
$ app -> match ([ ' get ' , ' post ' ], ' baz/ ' , function (){
view ( ' baz ' );
}); معلمات جهاز التوجيه:
$ app -> get ( ' hello/{name} ' , function ( $ name ){
$ this -> response -> write ( " Hello $ name ! " );
});
// Optional parameters
$ app -> get ( ' about/{category?} ' , function ( $ category = ' animals ' ){
$ this -> response -> write ( " Category: category " );
});
// Regex parameters
$ app -> get ( ' website/{((en|es|fr)):lang} ' , function ( $ lang ){
$ this -> response -> write ( $ lang );
}); الطريق الوسيطة:
// Global middleware:
$ app -> middleware ( function ( $ request , $ response , $ next ){
$ response -> write ( ' Global <br> ' );
$ next ( $ request , $ response );
});
// Global middleware (but not assigned to any route yet)
$ app -> middleware ( ' test ' , function ( $ request , $ response , $ next ){
$ response -> write ( ' Before route<br> ' );
$ next ( $ request , $ response );
$ response -> write ( ' After route <br> ' );
});
$ this -> get ( ' / ' , function (){
$ this -> response -> write ( ' Route <br> ' )
})-> middleware ( ' test ' ); // <- assign the 'test' middleware to this route
قريباً!
إذا كنت تحب عملنا ، فكر في دعمنا على Patreon