I am excited to finally announce PHP Apprentice! It is an online, free and open-source book for learning the PHP programming language. The book is a side project I have been building for six months. My goal is to provide a contemporary resource for learning the basics of PHP with a focus on high quality code. PHP has been around for 25 years and has changed a lot since its inception. A lot of the resources for writing good PHP have not aged well or are inapplicable today. I wrote PHP Apprentice to remedy the lack of available websites for learning PHP.
Currently, PHP Apprentice has chapters on the basic building blocks of the language, but in the future I will be adding sections on generating webpages, connecting to databases and advanced techniques like using Composer and autoloading. I am looking for feedback so please leave a comment here or an issue on the repository if you have any thoughts or requests.
Each chapter in PHP Apprentice was written as a Markdown file. I then built an HTML generator in PHP that takes each file and parses it with Parsedown into an HTML chunk and loads them with a template into a full HTML page. The pages are then served by GitHub pages. The build process can be performed using a CLI command so I automated the deployment using Travis CI. Whenever any code is merged into master
, Travis will pick it up, re-build all the webpages and push them to another branch on the repository which is used by GitHub Pages.
The frontend is all plain HTML, CSS and JavaScript. I used PostCSS to add file imports and variables. The code highlighting is performed by Prism.js. I wanted the focus of each page to be on the code so the styling is very minimal. The site is responsive, but has room to improve the experience on mobile. I focused on desktop since I recommend writing the code in the chapters while reading the book.
PHP Apprentice was inspired by Elixir School and Go by Example, two sites I admire for their clarity and quality. I hope that PHP Apprentice will become a similarly helpful site for the PHP ecosystem. It is a living book so I will be changing and improving the site over time.
Please check out PHP Apprentice and let me know what you think!