
Fuelphp in the field
Greetings to you, habraly people and those interested. Writing this post was a matter of time, so I did not postpone it and decided to write now. I previously published a description of Fuelphp's features. At that time, I just created a Russian documentation site, a group, wrote several test applications on this freemark.
In this article I want to share my experience in using this tool in a real project. It was necessary to make a remote admin panel and through api implement the management of client sites. Requirements: modularity, load optimization, use of Youtube API, CNC.
Next, I will indicate a specific task, but on the contrary I will describe what tools were used and how efficiently:
1. User authorization, including through vk and facebook social networks: Auth + oAuth + oAuth2: installed two missing packages through oil, connected in the config, started migration through oil, and then the necessary plates were created in the database. Everything worked like a clock, there was no vk driver, I wrote in 10 minutes.
2. Organization of templates: From the template engine refused in favor of optimization. There were two ideas on how to better organize the templates. The first was to define “widgets” in the base controller and then inherit from it. The second is to implement the “widgets" as separate modules and insert them using the HMVC request. The first seemed to me to be a simpler and more concise solution, since all the "widgets" somehow needed data from the database, and the same ones. Moreover, this data could be collected in one large cached request. I do not know how I made the right decision, but so far I have not encountered any problems, and query caching has increased the speed by almost 10 times.
3. Cyrillic CNC: 5 minutes time, it is really fast. urlencode () - urldecode ()
4. Sitemap generation: it was not found in standard packages. This is where all the charm of packages is revealed (package-package). I hit something like sitemap gen php on google that found a suitable class, after five minutes I already had the fuelsitemap package. Making packages in fuel is easy, it’s worth doing at least one and stopping is already impossible.
5. Implementation of the admin panel: here it was decided to prioritize the speed, since the backend was the same) extjs4 was chosen in the hope of speed of development and reliability. Reunited with fuel as a native. However, I will not use extJs4 anymore. This is a three-meter box with tools, you can do everything, and if you constantly work with it, it saves time, and you finally remember what and where it lies inside. This also includes updates, which can often break backward compatibility, imagine what will happen if you use extjs from time to time not well versed in its internals. A good solution for a studio where one or two people are busy over ui.
6. Admin api: There are several controllers in Fuelphp; this is a regular Controller, for implementing Controller_Template templates (a basic template is assigned via the $ template variable). To return xml, json, serialize and other formats, use either Controller_Rest or Controller_Hibryd (Controller_Template + Controller_Rest). And you do not need to prescribe anything anywhere else, just substitute .json or .serialize, etc. When you call a method, it itself converts the data into the desired format, inside the method the data is defined as an array.
6.1 Security API: Next, the question arose about security measures during data transfer. Firstly, it was decided to apply key data encryption, secondly, change the request method from get to post. Thirdly, enter access by passwords that were transmitted in the data itself and in the server header, of course also encrypted by key.
Crypt from fuelphp was used for encryption, but for the transfer of data and headers I wanted to use CURL. The scheme was standard google -> choosing a suitable wrapper -> making a package -> using.
7. Using the Youtube API: the previously created fuelcurl package helped here (as I called it) This task included for the most part logic that could be useful in the next project, so I didn’t want to “sew up” this solution in the controller’s methods. And so that I could easily and naturally use this functionality in the following projects, a separate fuelyoutube package was created.
8. Optimization:
Server
- nginx.
Code
- Standard features cached individual database queries.
- Api Yotube - a request to api occurs once, then it is taken from the database as a cache.
- Connected file cache.
It seemed to me sufficient to use these measures, at least at this stage. Although I understand that this is far from the limit of load optimization.
It took me two weeks to complete the development.
Notes:
- It turned out a flexible application, where almost all the little bit reusable logic was transferred into separate packages in order to reuse it in the following projects. Packages are something permanent and portable from project to project. You do it once and the solution does not disappear anywhere - this is really amazing.
- The controllers themselves only carry out checks and direct actions.
- The big advantage of packages is that you can reuse logic everywhere, in a template, in a controller, in a module.
- Over the entire time I’ve used the freework, I updated the kernel several times - backward compatibility did not break, the update came down to copy-paste with replacing the core folder.
- Fuel is as simple as you want, for example, I use unit testing, oil console, separation of development into dev and production, oil migration and much more. But I know one thing - when I need them, then I will easily start using them, since there is nothing complicated in Fuelphp.
That's all, all success and speedy implementation of plans. Offsite FuelPHP
- fuelphp.com FuelPHP
on GitHub - github.com/fuel
Test CMS on GitHub - github.com/samitrimal/mod-cms
Cheat Sheet -www.novius-os.org/fuelphp-cheatsheet/index.htm?utm_source=novli&utm_medium=novli&utm_campaign=fuelphp-cheatsheet
Russian documentation - fuelphp-framework.ru
Community at vk.com - vk.com/fuelphp
In this article I want to share my experience in using this tool in a real project. It was necessary to make a remote admin panel and through api implement the management of client sites. Requirements: modularity, load optimization, use of Youtube API, CNC.
Next, I will indicate a specific task, but on the contrary I will describe what tools were used and how efficiently:
1. User authorization, including through vk and facebook social networks: Auth + oAuth + oAuth2: installed two missing packages through oil, connected in the config, started migration through oil, and then the necessary plates were created in the database. Everything worked like a clock, there was no vk driver, I wrote in 10 minutes.
2. Organization of templates: From the template engine refused in favor of optimization. There were two ideas on how to better organize the templates. The first was to define “widgets” in the base controller and then inherit from it. The second is to implement the “widgets" as separate modules and insert them using the HMVC request. The first seemed to me to be a simpler and more concise solution, since all the "widgets" somehow needed data from the database, and the same ones. Moreover, this data could be collected in one large cached request. I do not know how I made the right decision, but so far I have not encountered any problems, and query caching has increased the speed by almost 10 times.
3. Cyrillic CNC: 5 minutes time, it is really fast. urlencode () - urldecode ()
4. Sitemap generation: it was not found in standard packages. This is where all the charm of packages is revealed (package-package). I hit something like sitemap gen php on google that found a suitable class, after five minutes I already had the fuelsitemap package. Making packages in fuel is easy, it’s worth doing at least one and stopping is already impossible.
5. Implementation of the admin panel: here it was decided to prioritize the speed, since the backend was the same) extjs4 was chosen in the hope of speed of development and reliability. Reunited with fuel as a native. However, I will not use extJs4 anymore. This is a three-meter box with tools, you can do everything, and if you constantly work with it, it saves time, and you finally remember what and where it lies inside. This also includes updates, which can often break backward compatibility, imagine what will happen if you use extjs from time to time not well versed in its internals. A good solution for a studio where one or two people are busy over ui.
6. Admin api: There are several controllers in Fuelphp; this is a regular Controller, for implementing Controller_Template templates (a basic template is assigned via the $ template variable). To return xml, json, serialize and other formats, use either Controller_Rest or Controller_Hibryd (Controller_Template + Controller_Rest). And you do not need to prescribe anything anywhere else, just substitute .json or .serialize, etc. When you call a method, it itself converts the data into the desired format, inside the method the data is defined as an array.
6.1 Security API: Next, the question arose about security measures during data transfer. Firstly, it was decided to apply key data encryption, secondly, change the request method from get to post. Thirdly, enter access by passwords that were transmitted in the data itself and in the server header, of course also encrypted by key.
Crypt from fuelphp was used for encryption, but for the transfer of data and headers I wanted to use CURL. The scheme was standard google -> choosing a suitable wrapper -> making a package -> using.
7. Using the Youtube API: the previously created fuelcurl package helped here (as I called it) This task included for the most part logic that could be useful in the next project, so I didn’t want to “sew up” this solution in the controller’s methods. And so that I could easily and naturally use this functionality in the following projects, a separate fuelyoutube package was created.
8. Optimization:
Server
- nginx.
Code
- Standard features cached individual database queries.
- Api Yotube - a request to api occurs once, then it is taken from the database as a cache.
- Connected file cache.
It seemed to me sufficient to use these measures, at least at this stage. Although I understand that this is far from the limit of load optimization.
It took me two weeks to complete the development.
Notes:
- It turned out a flexible application, where almost all the little bit reusable logic was transferred into separate packages in order to reuse it in the following projects. Packages are something permanent and portable from project to project. You do it once and the solution does not disappear anywhere - this is really amazing.
- The controllers themselves only carry out checks and direct actions.
- The big advantage of packages is that you can reuse logic everywhere, in a template, in a controller, in a module.
- Over the entire time I’ve used the freework, I updated the kernel several times - backward compatibility did not break, the update came down to copy-paste with replacing the core folder.
- Fuel is as simple as you want, for example, I use unit testing, oil console, separation of development into dev and production, oil migration and much more. But I know one thing - when I need them, then I will easily start using them, since there is nothing complicated in Fuelphp.
That's all, all success and speedy implementation of plans. Offsite FuelPHP
- fuelphp.com FuelPHP
on GitHub - github.com/fuel
Test CMS on GitHub - github.com/samitrimal/mod-cms
Cheat Sheet -www.novius-os.org/fuelphp-cheatsheet/index.htm?utm_source=novli&utm_medium=novli&utm_campaign=fuelphp-cheatsheet
Russian documentation - fuelphp-framework.ru
Community at vk.com - vk.com/fuelphp