Greetings to you, habra people and interested. Writing this post was a matter of time, so I did not delay it and decided to write now. Earlier, I have already published a description of the capabilities of Fuelphp. At that time I just created a Russian documentation site, a group, wrote several test applications on this free-form.
In this article I want to share my experience of using this tool in a real project. It was necessary to make a remote admin panel and via api to implement the management of client sites. Requirements: modularity, load optimization, use of the Youtube API, CNC.
Next, I will indicate a specific task, but on the contrary I will describe what tools were used and how effective:
')
1. Authorization of users, including through the social networks vk and facebook: Auth + oAuth + oAuth2: installed two missing packages through oil, plugged in the config, launched migration through oil - after which the necessary labels 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 template engines refused in favor of optimization. There were two ideas on how best to organize 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 perform their insertion using the HMVC request. The first one seemed to me a simpler and more concise solution, since all the “widgets” somehow needed data from the database, and some of the same ones. Moreover, these data could be collected in one large query. I don’t know how much I took the right decision, but so far I haven’t encountered any problems, and query caching has increased the speed almost 10 times.
3. Cyrillic CNC: 5 minutes of time, it is really fast. urlencode () - urldecode ()
4. Sitemap generation: not found in standard packages. This is where the beauty of the package is revealed (package-package). I drove into google something like sitemap gen php found a suitable class, in five minutes I already had a fuelsitemap package. To make packages in fuel easier, it is worth making at least one and it is already impossible to stop.
5. Admin implementation: it was decided to assign speed priority, since the backend is 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 tool box, you can do everything, and if you constantly work with it, it saves time, and you finally remember what is inside it. This also includes updates that can often break backward compatibility, imagine what would happen if you use extjs from time to time not well understood in its insides. A good solution for a studio where one or two people are busy over ui.
6. Api admin: In Fuelphp there are several controllers, this is the usual Controller, for implementing the Controller_Template templates (the 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 don't need to prescribe anything anywhere else, just substitute .json or .serialize, etc. When you call a method, it converts the data into the required format, the data inside the method is defined as an array.
6.1 Security API: Next came the question of security measures for data transmission. Firstly, it was decided to apply data encryption by key, secondly, to change the request method from get to post. Third, 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 I wanted to use CURL to transfer data and headers. The scheme was standard google -> choosing the right wrapper -> making a package -> using.
7. Using the Youtube API: here the previously created fuelcurl package helped (as I called it). This task included mostly logic that could be useful in the next project, so I didn’t want to “sew up” this solution in the controller 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 requests to the database.
- Api Yotube - the request to api occurs once, then it is taken from the database as a cache.
- Connect the file cache.
It seemed to me that the use of these measures was sufficient, 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 - it is really amazing.
- The controllers themselves only perform 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.
- For all the time of using the freeware, I updated the kernel several times - backward compatibility did not break, the update came down to copy-paste with the replacement of the core folder.
- Fuel is as simple as you want, for example, I use unit testing a little, oil console, dev and production development, oil migration and much more. But I know one thing - when I need them, then I can easily start using them, since there is nothing difficult in Fuelphp.
That's all, all the success and early implementation of plans.
Offsite FuelPHP -
fuelphp.comFuelPHP on GitHub -
github.com/fuelTest CMS on GitHub -
github.com/samitrimal/mod-cmsCheat Sheet -
www.novius-os.org/fuelphp-cheatsheet/index.htm?utm_source=novli&utm_medium=novli&utm_campaign=fuelphp-cheatsheetRussian documentation -
fuelphp-framework.ruCommunity in vk.com -
vk.com/fuelphp