![]() If a framework uses dependency injection, it should comply with the standards outlined in the PSR-11 Container Interface specification from the PHP Framework Interop Group (PHP-FIG). To simplify code management, most modern frameworks provide dependency injection containers for managing the various handlers they expose, and the services that act as their dependencies. And based on what they do, they may require other objects as dependencies. And re-purposing code for re-use, or moving code to new locations based on new requirements, can make this approach even less attractive.įrameworks can automatically match every request to a handler by using "controllers" or "request handlers.” Controllers and request handlers are generally written as PHP objects. However, when you take this manual approach, applications quickly become an unmaintainable mess. You can hand-wire handlers and dependencies in your code. To match a request to a handler, you need to obtain the handler and all its dependencies. Framework Consideration: Controllers, Request Handlers, and Dependency Injection Deliver a response in the format the user expects - whether that's an HTML page, an RSS feed, or JSON.Marshal any data sent to the structures the application expects.Determine if the request is well-formed. ![]() Creates and returns responses to requests.įor example, for each request, the framework should be able to:.To help ensure the framework you choose can meet your requirements today and into the future, it’s important to review how it: PHP Framework Consideration: HTTP Negotiation The importance of the last eight capabilities will depend completely on your requirements. And with some in-house architectural and structural guidelines, you can develop anything. If your framework provides them, you can save time and improve application quality. The first four capabilities listed are the most critical. Controllers, request handlers, and dependency injection.Deciding which one is best for you is easier when you compare how each framework addresses the following 12 capabilities in relation to your requirements: There are many frameworks to choose from including Laminas (formerly Zend Framework), Laravel, Symfony, Nette, Yii, and CakePHP. Top 12 Considerations When Choosing a PHP Framework At a minimum, frameworks manage HTTP negotiation, dependency graphs, templating, and error handling. That’s because PHP is most often used for web development. A PHP framework provides the core infrastructure for turning an incoming HTTP request into an HTTP response.
0 Comments
Leave a Reply. |