I recently stumbled on the PHP in 100 seconds video from Fireships fantastic 100 second series and a comment by one user gave me a smile and struck a chord. The top comment was: “Finally, the final boss of the 100 seconds series”. That pretty much sums up my thoughts.
Returning to writing code after a long stint in management, I’ve been playing around with various frameworks and languages over the past 12 months, trying to find my feet in a new, largely Javascript dominated world. I’ve dabbled with Nextjs, Nuxtjs, Rails, which I never got to in the past, and even Go for some minor scripting tasks.
I then decided to build my consultancy site using Astro coupled with a headless CMS before I thought, wouldn’t it be simpler if I just used Laravel for this? I already have cloud servers and use PHP on a daily basis building Magento stores so wouldn’t it be more productive to just use what’s tried and tested without these additional services?
That’s not knocking Javascript frameworks and granted, monoliths aren’t the in thing at the moment but PHP gets an annoyingly bad rap in the community. Scalability, concurrency, legacy codebases… WordPress. Let’s be honest though, it powers most of the web and it’s only gone from strength to strength over the years, with significant improvements that make it a solid choice for development in 2024.
I thought I’d pull together some thoughts on why PHP remains relevant and highlight features and tools specifically from Laravel and Symfony that demonstrate its continued evolution.
1. The Evolution of PHP
PHP, criticised for its inconsistent syntax and performance issues, has undergone substantial changes over the past decade. The language has evolved with major releases, introducing new features and performance improvements that make it competitive with modern languages.
2. Usage Stats
- Market Share: PHP powers approximately 77% of all websites with a known server-side programming language, according to recent statistics. This widespread usage underscores its importance in the web development landscape.
- WordPress Dominance: WordPress, the world’s most popular CMS, is built on PHP. It powers over 40% of all websites on the internet, including millions of personal blogs, news sites, and major corporate websites.
- Wikipedia and Beyond: Wikipedia, one of the largest and most-visited websites globally, relies on PHP for its backend. The Wikimedia Foundation utilises PHP to handle the vast amount of data and traffic it receives daily.
3. Key Improvements
- Performance Enhancements: PHP 7 brought significant performance improvements with the introduction of the Zend Engine 3.0. PHP 8 has continued this trend, with Just-In-Time (JIT) compilation further improving execution speed. These advancements make PHP applications faster and more efficient.
- Improved Type System: PHP has gradually introduced scalar type declarations, return type declarations, and union types, making it easier to write more robust and maintainable code. The language now offers better support for modern programming practices and design patterns.
- Error Handling: The introduction of exceptions for error handling has replaced the older error reporting system, making it easier to catch and handle errors in a consistent manner.
- Modern Features: PHP 8 introduced features like named arguments, attributes, and match expressions, aligning the language with modern programming paradigms.
4. Laravel
Laravel has emerged as one of the most popular PHP frameworks, known for its elegant syntax and developer-friendly features. It simplifies common tasks such as routing, authentication, and caching, allowing developers to focus on building robust applications.
Notable Laravel Packages
Huge shoutout to the Filament team as this package has got a few of my projects off the ground in record time. Filament simplifies the creation of beautiful and interactive admin panels in Laravel applications. It provides a set of components and utilities that make it easy to build complex admin interfaces with minimal effort.
- Livewire Integration: Filament seamlessly integrates with Livewire, allowing developers to build dynamic interfaces without writing JavaScript.
- Customisable Components: Filament offers a wide range of customisable components, such as tables, forms, and modals, enabling developers to create tailored admin experiences.
- Resource Management: Filament simplifies resource management with an intuitive API for defining and managing resources, actions, and permissions.
Livewire is a powerful package that enables developers to build dynamic, reactive interfaces using Laravel’s Blade templates. It eliminates the need for a separate frontend framework, allowing developers to leverage their existing PHP skills.
- Real-Time Updates: Livewire enables real-time updates to the UI without requiring page reloads, providing a smooth and interactive user experience.
- Server-Side Rendering: Livewire components are rendered on the server, ensuring fast initial page loads and improved SEO.
- Declarative Syntax: Livewire’s declarative syntax makes it easy to define interactive behaviour directly in Blade templates, reducing the complexity of JavaScript-heavy applications.
Inertia is a package that allows developers to build modern single-page applications using familiar server-side frameworks like Laravel. It acts as a bridge between the server and client, enabling seamless integration of server-side rendering with client-side interactivity.
- Vue.js Integration: Inertia integrates seamlessly with Vue.js, allowing developers to build rich, interactive interfaces using Vue components.
- Simplified SPA Development: Inertia eliminates the need for a separate API layer, simplifying the development of SPAs by allowing developers to leverage Laravel’s routing and authentication features.
- Shared Data: Inertia provides a simple mechanism for sharing data between the server and client, making it easy to manage application state and reduce code duplication.
5. Symfony
Now I have limited to no commercial experience with Symfony, beyond getting class errors but that’s a Magento thing, but it’s another hugely popular and powerful PHP framework most often used in enterprise scenarios due to its flexibility and scalability. It provides a robust set of components and tools that can be used independently or as part of a larger framework.
Notable Symfony packages
API Platform
API Platform is a powerful tool for building RESTful APIs with Symfony. It provides a set of features and tools that simplify the development and management of APIs, allowing developers to focus on delivering robust and scalable solutions.
- Automatic CRUD Generation: API Platform can automatically generate CRUD operations based on your data model, reducing the need for boilerplate code.
- GraphQL Support: API Platform supports both REST and GraphQL, allowing developers to choose the most suitable API style for their applications.
- Extensible and Customisable: API Platform is highly extensible, enabling developers to customise serialisation, validation, and security to meet specific requirements.
EasyAdmin is a powerful package for building admin panels with Symfony. It provides a simple and intuitive interface for managing data, making it easy to create and customise admin interfaces.
- Configurable Dashboards: EasyAdmin allows developers to create custom dashboards with widgets and charts, providing insights into application data.
- Flexible Form Configuration: EasyAdmin offers a flexible form configuration system, allowing developers to customise the layout and behaviour of forms in the admin panel.
- Role-Based Access Control: EasyAdmin supports role-based access control, enabling developers to define and manage permissions for different user roles.
Doctrine ORM is a powerful object-relational mapping tool that integrates seamlessly with Symfony. It provides a robust and flexible approach to managing database interactions, allowing developers to focus on application logic.
- Advanced Query Capabilities: Doctrine ORM provides a powerful query builder and support for advanced query techniques, enabling developers to retrieve and manipulate data efficiently.
- Database Migrations: Doctrine ORM includes a robust migration system, making it easy to manage database schema changes and ensure consistency across environments.
- Entity Lifecycle Management: Doctrine ORM provides features for managing entity lifecycle events, allowing developers to implement custom logic at various stages of the entity lifecycle.
6. Final thoughts
The PHP ecosystem continues to evolve, with ongoing efforts to improve performance, security, and developer experience. The language’s active community and large user base ensure that PHP remains a relevant and competitive choice for web development.
PHP’s vibrant community and extensive ecosystem of libraries and frameworks contribute to its continued relevance. The active development of frameworks like Laravel and Symfony, along with a wealth of third-party packages, ensures that PHP remains adaptable to changing industry trends and developer needs.
PHP’s transformation over the years has made it a strong contender in the web development landscape. With modern frameworks like Laravel and Symfony, PHP offers a powerful and flexible platform for building robust applications. The language’s continued evolution, combined with a rich ecosystem of tools and packages, ensures that PHP remains relevant and valuable in 2024 and beyond.
As a developer returning to PHP, you’ll find a language that has matured significantly, offering new opportunities and possibilities for building modern web applications.
I’m an ecommerce consultant specialising in PHP frameworks like Magento and Laravel, helping retailers build and optimise scalable, high-performance applications. If you need help planning a new build or improving an existing site, get in touch to see how I can support your project.