Yesterday, a tweet from Chris Cornutt made me think a lot about how it is nowadays to get started, from the very beginning, with PHP.
It's easy to forget that there's a lot of people out there coming new to PHP every day that need guidance and help for the basics. Chris Cornutt
This post is a collection of things that I consider important for people who are starting with PHP, based on my experiences with this language through the years.
PHP has considerable evolved in the last years, thanks mainly to the community efforts. Comparing to the early days, we have a much more strong language and an amazing community. As a downside for the language evolution, as things change, tutorials and practices might get deprecated. So we have a lack of good updated tutorials for beginners.
Another thing to notice is the framework explosion - Symfony and Zend, for instance, are widely known and figure as a common requirement for job opportunities. There's nothing wrong with frameworks, but they are not really beginner-friendly in my opinion. That leads to my first advice:
Learn the language, not a framework
Keep it simple for learning, try to write your own pieces of code, think about something funny to write and practice your PHP skills. Experiment. Don't start tied to a framework, because then you will be dependent on it, and you will probably not understand how it works behind the scenes.
I'm not condemning the use of frameworks whatsoever, because they help a LOT and you are not supposed to reinvent the wheel. But to really learn a language, you need to study the language itself, that way you will be able to understand any framework you come across.
If you don't have a previous background on programming languages, you should definitely study some theory regarding Object Oriented Programming and Design Patterns. This will really help you to write good code.
And one more really important thing: have a look at PHP - The Right Way. You will find excellent explanations about the best practices in PHP and guidelines for a clean and readable code. This website is a must-have in your bookmarks.
The next thing you need to study is Composer, no doubt about that. Composer is a dependency manager for PHP, and I honestly think that we can separate PHP history in before / after Composer. With a simple JSON file you define your project dependencies, and running
composer install will download the right versions of the libraries you need, directly from their repositories. Maintaining your project dependencies up-to-date was never so easy.
Git and Github
Git is turning into the default for distributed version control and source code management in modern projects. It was created by Linus Torvalds and popularized by Github, the most amazing space for collaborative coding, either open source or not.
Now that you know the important stuff and have a good basement, its a good moment to try some frameworks. To have a better understanding on how the frameworks are built, its strongly recommended that you study the MVC architecture pattern - thanks @vipulbhatia99 for suggesting this additional note.
To get more expertise and get acquainted with new libraries and frameworks, the best thing to do in my opinion is contributing to open source projects. There are a lot of PHP open source projects on Github waiting for your contribution, it doesn't need to be huge, every help counts.
Also, try to get in touch with other developers, user groups are amazing for that. IRC (Freenode) is also a great alternative to communicate with other PHP developers around the world and get some help - try the channel ##php for starting.
Hope this may help someone getting started with the language that I embraced :) <3 <3
- Start simple
- Learn the language, not a framework
- Use PHP - The right way as a reference for good PHP practices
- Study the Tools - Composer, Git
- Have a look at the frameworks and pick one, start simple
- Get Involved in Open Source projects and with the PHP community