The following is a guest post by Aydin Hassan, who is going to introduce to you a really compelling way to learn PHP. I’m sure all of us get asked by our less experienced acquaintances “how do I get started with X?” or even “what book should I buy?” Books can be great, but given the choice, learning code by actually coding in an interactive environment will do you better.
I had great fun and the workshops were really cool – you select an exercise, read the problem and start coding. Each exercise explains concepts and links to resources. Once you have written a solution to the problem, you invoke the workshop with your solution. Your solution is then ran and information regarding your success (or failure!) is printed to the terminal.
I’m a PHP developer by trade – the next day I thought to myself: is there something similar for PHP? There must be something similar for PHP? Turns out there wasn’t!
In this post we will talk a bit about why we built it, how you can run one of the workshops and finally, how you can get involved.
Completely open source – the framework is open source, the website is open source and so are the actual workshops. We have been building and refining PHP School for the last ~9 months. There is still lots for us to do and we plan to build many more workshops.
For the time being we have one workshop Learn You PHP! – a PHP port of Learn You Node. We decided that the format worked so well, we would build the initial workshop as similar as we could.
Why did we build it?
We felt like there was a serious lack of professional learning resources for PHP, for one of the most popular web development languages, we thought this was strange. There are of course good resources, for example PHP – The Right Way, SitePoint – PHP, Laracasts and more, but there is nothing like PHP School.
What really impressed us with NodeSchool was the fact it was so suited to meet-ups and organised workshops. Everyone installs the software and attempts the exercises – the organisers, volunteers or elected persons can walk around and help out any body getting stuck or just answer questions. All of the verification process is automated by the application.
We built the framework so people could easily build their own workshops. This allows us, as a community to focus on the teaching, on the material, not the logistics. This is a tried and tested concept as seen with the NodeSchool community.
Hopefully we can lower the barrier to coding!
Getting set up
Unfortunately if you are running Windows then it is not so simple to install. Not impossible but not easy. This guide will focus on Linux installations but if you want to try it on Windows you can follow our instructions over at our website.
In order to install Learn You PHP! there are a couple of requirements.
You will also need to make sure Composer’s global bin directory is added to your $ PATH environment variable, you can check how to do that on the Composer site.
Open up a terminal and run:
$ composer global require php-school/learn-you-php:~0.1
Editor’s note: for the beginners out there, the “$ ” you see in lines like above designates “the end of your command prompt”. Your’s may look different. Mine is “Chriss-MacBook-Pro-2:~ chriscoyier$ “. If you are copy and pasting the command, don’t copy the “$ ” part.
This will install Learn You PHP! globally on your system. You should be able to run it by typing:
You will be presented with a menu containing a list of exercises. You can navigate around the menu with your arrow keys and exit using the exit button. Select an exercise by hitting enter.
A problem will be printed to the terminal, including in it will be a description of the problem and some links to digest. The first exercise “Hello World” requires you to write a program which prints the text “Hello World”, so lets do that!
First, we need a folder to contain our work, lets go for: `learnyouphp` in our home directory
$ cd ~ $ mkdir learnyouphp $ cd learnyouphp
Open up a text editor and place the following code in there:
<?php echo "Hello World";
Save this as a file named helloworld-solution.php in the folder we just created. Now we can jump back to the command line and verify our exercise:
$ learnyouphp verify helloworld-solution.php
You should receive a message describing your solution as a success.
So, you completed your first exercise – you can now move on to the next exercise, each exercise increases in difficulty whilst introducing new concepts in PHP!
Intro & Installation Video Walkthrough
These workshops are something we’d like to run at meet-ups and other events, if you are interested in using the workshops go ahead and use them, give us a shout if you need any help, or just to let us know what you are doing and how well it went.
We’d love the community to grow to the size of Node School and more – we will hopefully be organising some meet-ups our selves to get the ball rolling soon.
There are lots of things you can do:
Host a workshop event
Propose a workshop to your user-group organiser
Help build more workshops
We plan on growing the workshop library, so if you want to build a workshop, head over to the documentation on our website. The documentation is being bulked out over the coming weeks so check back regularly for documentation on more advanced features.
If you want to host a meet-up using PHP School, give @aydin_h or @mikeymikemw a shout and maybe we could come along to help set it up.
Hopefully this article has inspired you – maybe you will go ahead and learn PHP using PHP School. Maybe you will use PHP School at a meet-up you organise or propose it to the organisers of one you attend. Maybe you will build your own workshop to teach a topic or showcase your tool.
I think we can all agree that education and learning are of great significance to this and future generations. Technology is a huge part of our evolution and can solve many of the world’s current issues. Programming is a small part of that – and you can learn to code!