PHP Framework what should and should not do

PHP Framework what should and should not do

Today, when it comes to PHP programming, most programmers think of a means of PHP Framework. Because it helps programmers minimize the time to rewrite basic operations. Moreover, PHP Framework also gives programmers a lot of time to research and update new technologies, because they do not take too much time to explore or apply the knowledge that is basically too boring with them in projects.

Indeed, the PHP Framework is now quite complete and meets most of the necessary and sufficient conditions for building a project. Speaking of Framework, the most prominent are still veteran and old like: Zend Framework, CodeiGniter Framework, CakePHP Framework, ….

These frameworks focus on the smallest details in programming. In order to reduce the load time for their users. Such as helpers help users build forms, helpers help users use HTML tags, helpers help users validate forms and data, etc.These things, in fact only contribute to making The framework has become more user-friendly and familiar.

But in fact, the PHP Framework also has implications for many elements of the application or more seriously still the human element. In this article, let’s analyze. What issues need attention and attention when operating regardless of PHP Framework.

Need or not need such helper?

If you have to ask programmers, “Do you know HTML? Do you know how to create forms with HTML?” Many people will laugh and think that you are doing redundant things. At the level of a programmer. That is a basic factor for them to learn, so why are we waiting for a PHP Framework to do such work instead.

Yes, of course good. But neither does it affect anyone. Moreover, updating these libraries will make the application slower and more difficult to operate. One thing that the PHP framework has always been affected by.

Model of difficult problems for frameworks:

Most PHP Frameworks are based on the M-V-C model one of the design patterns. This model will separate the code into 3 different partitions with 3 different responsibilities. The controller will take the role of receiving requests (requests) to pass them on to the Model. The model will now operate pure Active Record or SQL structures to retrieve information from the database and then dump them into an array.

Now when the controller makes a request to any request it will push that array of information into the view. In the view to get the values ​​in the array, we have to browse the array to retrieve each single element like that. This makes the application more sluggish. Contributing to increase% “tortoise” of PHP Framework.

Autoload – critical element that slows down the framework:

To make it easy for users to run libraries, PHP frameworks often allow the autoload feature to always be enabled on everything. This helps programmers not waste time creating objects when needed. Because they have been invoked as soon as we have access to the controller. Seems more beneficial to you guys.

But in reality, the autoload itself becomes a difficult problem when the user calls any object. Because not all controllers need the same libraries. It depends on what the controller’s request is and how. Therefore, never force our PHP Framework to load all libraries. It is beneficial, but if benefit 1 then harm will be 10 for your application.

Object-oriented – the eternal story for frameworks:

To make the code coherent, to be transparent. Programmers all want to put their code in the direction of the idol team. To help them promote the inheritance and effectively operate what they have done with previous applications. Moreover, the object-oriented model (Object-Oriented Programming) is also a strength of PHP.

So, so that the programmers constantly build their code in that direction. It is true that OOP makes the code transparent and clear, but the misuse of OOP will have the opposite effect with the benefits that we always want. Should apply OOP skillfully with design pattern to maximize the power that OOP has.

And overslept thinking – a worrying concern for programmers:

The PHP Framework is one of the significant strides of PHP. By building a series of libraries to help users solve problems scientifically and without having to redo the operations that are too basic. But it is because of these that PHP Framework makes programmers have a habit of relying seriously on PHP Framework.

For example, in CodeIgniter version 1.7.2, CodeIgniter has supported users with the shopping cart, image library, etc. This accidentally caused PHP programmers to think lazily in applying and develope. For them, creating an online cart is simply hook, hook, point, point. Call that class, call this class done. Accidentally the PHP Framework has killed the programmer’s mind.

People often ask for a dish that is delicious, quality and processed very quickly. Then when they have such food, they always think that eating is the right way and saving time. But in fact, the consequences of using “fast food” always bring inadequacies in many aspects. For example, if a dish is quickly processed, how can it be clean, but when it is not clean, it is more harmful to use the body than it is effective.

The same is true for the PHP Framework, if programmers only rely on the PHP Framework and forget that the PHP Framework is also made up of the knowledge they have. Surely, that developer will not be able to escape the great shadow of the PHP Framework. So as a programmer, we should have the right perspective.

When the PHP Framework provides a new library, do not hesitate to read how they solve that problem. From there, we can draw the improvements and optimizations that PHP Framework brings back. Not to mention it will add a huge amount of knowledge for you to read deeply and learn about the operating cycle of any PHP Framework library.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *