PHP¶
PHP - the "PHP: Hypertext Preprocessor" - was originally released as "Personal Home Page Tools" by Rasmus Lerdorf in 1995. The reference implementation is now produced by The PHP Group.
Also see History of PHP and Related Projects.
It is a scripting language with a syntax similar to C and Perl intended to create web based applications.
Originally PHP started as a simple scripting language to make creating websites with dynamic content easier. Over its history it evolved into a quite powerful object oriented language with a debugger interface, just in time compiling, classes, namespaces, reflection, attributes, exceptions, fibers to name some of the features provided in version 8.1.
Package management with Composer¶
Composer is an application-level dependency manager for PHP which is used by many frameworks. Packages are usually hosted on packagist.org, however you can also maintain a local package repository if needed.
Libraries and frameworks¶
About frameworks in general¶
Many frameworks often share similar concepts and design patterns like the following:
- Routing: map a specific URL to a controller method to be called which usually also gets the parameters passed in the URL as either variables of the method or in a request object containing all parameters.
- Controllers: classes which provide methods which can be called using routes and provide responses either as HTML or JSON or any other datatype which suits the requirement.
- Entities: entities are used to query and store data in databases. This also includes ORM (object relational mapping).
- Services: services provide methods to execute actions like fetching data, create a new entity, send an e-mail and so on.
- Commands: commands will be called at the command line level using the PHP CLI.
- Dependency injection: classes which are a required dependency for other classes or methods can be provided as parameters in class constructors or methods and will be automatically instantiated if needed.
CodeIgniter¶
Website: https://codeigniter.com
First release: 2006
License: MIT
CodeIngiter is an application framework maintained by the British Columbia Institute of Technology and originally developed by Ellis Labs. If followisthe model view pattern and was designed to be easy to use and configure.
Symfony¶
Website: https://symfony.com
First release: 2005
License: MIT
Symfony is an application framework maintained by Sensio Labs. Package management is done using Composer and Symfony Flex. Besides routing and controllers it provides the concept of services and dependency injection. You can also create command line commands. Database access is done using Doctrine and the preferred UI renderer is Twig.
Doctrine¶
Website: https://www.doctrine-project.org
First release: 2006
License: MIT
Doctrine provides an abstraction layer to work with databases using ORM with entities and repositories. Instead of using SQL you can build queries with a query builder or with DQL, the "Doctrine Query Language". DQL is similar to SQL but uses Doctrine entities and their properties instead of table and field names.
Doctrine is used by a number of frameworks, as of 2022:
Twig¶
Website: https://twig.symfony.com
First released: 2009
License: BSD
Twig is a template engine which was originally developed for Symfony but can be used without Symfony as well. There is also a JavaScript version at https://github.com/twigjs/twig.js.
API Platform¶
Website: https://api-platform.com
License: MIT
API Platform is a set of components to create hypermedia REST or a GraphQL API with pagination, data validation, access control, relation embedding, filters and error handling.
Also see the Github repository at https://github.com/api-platform/api-platform.