The PHP founder, Rasmus Lerdorf, was asked to speak at the PHP Frameworks Day Conference. Most of what he said was about new PHP advances, but you found the most significant interest in the question-and-answer portion.
Someone also inquired about Rasmus; thoughts on the PHP frameworks that are helpful for PHP developers in India. They (PHP frameworks) all stink, Rasmus responded directly to the straightforward inquiry about his view (almost 31 minutes and 47 seconds).
It may sound strange for a guest speaker to tell everyone at a PHP frameworks conference that they are all garbage. However, the crowd liked the response. Rasmus clarified his meaning further, though.
Without Purpose, Frameworks Repeatedly Run the Same Piece of Code
A more specific concern was that the solutions provided by frameworks resulted in the repetitive execution of unnecessary PHP code in each HTTP request. Rasmus used the example of how every request framework checks the kind of database the application is using before loading the appropriate database access class. Thus he considers this to be a waste.
While we all agree with Rasmus, we don’t think this example is compelling because it only takes a minimal amount of time to check the configuration to determine which database access class to load, especially when compared to, for example, running database queries, which typically take many milliseconds and occasionally take a few seconds to complete.
Frameworks often access INI files for configuration. Even though you can do everything with a single function, reading and parsing an INI file often takes more time than verifying the parsed configuration variables.
This is because frameworks must do the parsing in pure code. That is much slower than the PHP engine’s C code parsing INI files.
Having configuration settings specified in PHP script files is a preferable solution. Include the configuration settings in the PHP scripts that define the variables and their values.
A PHP caching extension only requires one compilation of PHP programmes. Compared to loading settings from files, it is significantly quicker.
Frameworks Need too Many Interdependent Classes.
Rasmus also points out that sometimes you require particular components of a framework.
Nevertheless, there are often dependencies between several foundation classes that sometimes don’t combine anything for a particular application.
To solve this issue, some programmers may need to modify the frameworks to remove the unnecessary overhead components.
Rasmus advises using frameworks designed for specific uses to get around this issue. If you only want to write a blog, he suggests utilizing WordPress or Drupal.
These elements enable programmers to specify how to query databases that regard data as objects rather than lists of records.
Object orientation is suitable for encapsulating solutions and abstracting issues into class objects. However, the way certain ORMs operate adds high cost.
Better alternatives exist that do away with this overhead. Have a unique tool that creates PHP code for the ORM classes rather than building queries dynamically at runtime.
This strategy has been used by me since we created the ORM utility known as Meta Storage in 2002. It does everything we said before. The objects, variables, relationships, and functions we need to use on things are defined in the project file.
My objects’ definitions are processed by Metal storage, which creates ORM classes that conduct the required queries at runtime when called through the classes’ functions. At runtime, no query construction is done.
Overly Difficult Solutions
Rasmus should have specifically addressed the overly complex solutions that frameworks often promote.
For instance, application version migrations are an example of this. Other frameworks have used the Ruby on Rails notion of migrations. You must write code to modify your database schema between various application versions.
Another issue that Metastorage handles more effectively and pleasantly for developers is this one. Metastorage produces database table schema definitions in a different file than my object definitions. It creates an installation class that first installs the database tables.
By manually writing migrations code, you run the risk of making errors that require more time and work to correct.
Reproducing the Functionality of the Web Server
Another point Rasmus did not specifically address has to do with the fact that frameworks sometimes call for PHP code to repeat tasks that the Web Server has previously completed.
Many frameworks encourage the usage of the front controller approach in applications. In order to process the request, the front controller examines the request URL and loads a particular controller.
It is another negative impact that Java and Ruby on Rails have on PHP frameworks. The Web server sends the request to an application server when it encounters specific languages.
Rasmus’ interview was quite intriguing since it caused us to consider how we may be using general-purpose frameworks in PHP in an unsatisfactory manner.