flyr php micro-framework

Download Flyr PHP micro-framework

Post on 16-Jul-2015




0 download

Embed Size (px)


  • Flyr PHP micro framework

  • There are a lot of frameworks, each one with their particularities. There are really good frameworks like laravel, codeigniter, cakephp, etc.Flyr wants to be easy, simple and extensible. The goal is develop a fast micro-framework which be so fast as user needs to develop applications.

    Why try to remake validators, uploaders, orms and more software pieces if you can find them in github with great quality and well tested?Then you can add those libraries with a package manager like composer in your flyr project.Why another framework?

  • Flyr comes with a set of utilities: - Router system with support for GET, POST, PUT and DELETE methods. - Simple log component with email and file support. - Http header manipulation. - Cookies encryption. - Simple cookie and session api. - Easy multi-language component. - Twig and php templates. - Simple application skeleton for organize your project. - Little mail sender support with PHPMailer.What contains Flyr?

  • Installing flyr is as simple as creating a composer project or downloading the zip file inside the flyr github REPOSITORY that contains all packages needed to run your application.

    Run the following command to start a new project(at the current moment): > composer create-project flyr/flyr:1.0.*@dev Or simply download in

    Now you have installed a copy of Flyr framework and you are ready to start developing.How to install Flyr?

  • You can design a REST API easily using four request methods: GET, POST, PUT and DELETE. Also, each route can contain parameters.Finally you can pass a callback(anonym function) or the controller and method name. This last option would be better for organize your project.

    To resume this part you will see a few lines of code to understand better all refered to routes.


  • Routes example

  • Flyr also provides support for simple PHP templates (with tags ) and Twig template engine.You can render templates with the render method.But not only one template can be rendered for show in the browser, also you are able to render multiple php or twig templates calling multiple times render method.

    All templates are saved inside the folder app/views/ and all Twig templates are automatically cached.


  • Views example

  • For developing the REST of APIs you will need to return in your response body a data type like JSON or XML and must be defined the response encoding as application/json or text/xml for each data type.

    You can set all response headers using the header->set method.Maybe you need to remove headers like X-powered-by , redirect or send a response code. It is simple and you can see the following examples using header object.HTTP headers

  • HTTP headers example

  • Session and cookies have a new API for make many actions in the correct way like deleting sessions and cookies, encrypting cookies or prevent cookie access from the browser.In the PHP cofiguration file (Flyr/Config/php_config.php) cookies and sessions are correctly cofigured for avoid main source of session hijack.

    Cookies methods are: create, delete, deleteAll, set, get.Session methods are: start, set, get, delete, deleteAll.

    You can see the following examples:Managing sessions and cookies

  • Cookies and sessions exampleSession exampleCookie example

  • Other important object is the flyr loader. You can load helpers and language files. Helpers are files containing functions or classes to solve a specific group of problems. For example, you can create a file called string_helper.php that has some functions to manipulate strings.

    In the following example you can see how to load a language file containing the seven days in Spanish:Loader

  • Loading a language file exampleA language file with an associative array styleLoading the language file named days.php inside the language folder es

  • ThanksTo know more about Flyr micro-framework and read the full documentation visit

    Fork and star the project