Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Flyr PHP micro-framework

307 views

Published on

Flyr is new PHP web framework designed for programmers who want to create fast a REST application with an easy API and an simple architecture to organize the project. Flyr supports Twig views and secure cookies and much more.

It has been developed thinking in flexibility. What it means? easy. You can install all required modules from third party avoiding overload the server with unnecessary libraries. In other words, you can install the ORM that you want, validation library and so more.

Visit https://github.com/SiroDiaz/Flyr

Published in: Software
  • Be the first to comment

  • Be the first to like this

Flyr PHP micro-framework

  1. 1. Flyr – PHP micro framework
  2. 2. 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?
  3. 3. 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?
  4. 4. 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 Flyr.zip in https://github.com/SiroDiaz/Flyr. Now you have installed a copy of Flyr framework and you are ready to start developing. How to install Flyr?
  5. 5. 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
  6. 6. Routes example
  7. 7. • Flyr also provides support for simple PHP templates (with tags <?php ?>) 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
  8. 8. Views example
  9. 9. 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
  10. 10. HTTP headers example
  11. 11. 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
  12. 12. Cookies and sessions example Session example Cookie example
  13. 13. 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
  14. 14. Loading a language file example A language file with an associative array style Loading the language file named ‘days.php’ inside the language folder ‘es’
  15. 15. Thanks To know more about Flyr micro- framework and read the full documentation visit https://github.com/SiroDiaz/Flyr Fork and star the project

×