Learning Laravel - part II

If you just happened upon this page without reading my neat introduction, you can find it here http://particle-in-a-box.com/blog-post/learning-laravel-part-i.

How I learn stuff

Whenever I start learning something, whether it be an instrument, a language or a piece of software, I always jump right in without paying much attention to the disclaimers. I'm not the type to study, meditate and prepare before getting down to business. Of course sooner rather than later I will buy the book and I will study, but not before I have experienced some hands on action with the actual thing. Learning a programming language of course you need a few syntax basics, but sometimes the grammar can be surprisingly intuitive. After all it's all made by humans with a certain goal in mind. If I am trying to use a particular tool I must be having a very similar goal as the creator of the tool. Reconstructing the mind of the creator can be a very rewarding game. Then if you hit a wall, better get the book.

With respect to intuitiveness, Laravel was not too generous. At least not to me. I had little experience with similar app-building frameworks and since I skipped the introduction I hit the wall pretty darn fast.

Laravel: first steps

After finding out about Laravel the first thing I did was visit their minimal and beautiful homepage https://laravel.com/. "Love beautiful code? We do too." is their flattering welcome line. Ya, it works. Because which programmer wouldn't want to be someone who loves beautiful code? They give the whole coding business a certain kind of high literature slant and that's kind of refreshing. What I missed on this visit was a big button that says "install laravel". DuckDuckGo sent me right back to laravel.com, however and straight into the docs. I followed the installation instructions using Composer which offers a brand new command:

laravel new [sitename]

Pretty elegant. After pulling in all the files my terminal said "Application ready! Build something amazing." Sounds good, and according to the documentation that was it. Laravel was supposed to be installed on my server (which is a LAMP stack by the way). So, I created a virtual host pointing to the root of my new exciting project, hit the browser and was disappointed by a very ugly index page obscenely displaying the guts of Laravel.

Maybe I missed something in the documentation? but the next steps seemed way down the line from my predicament and the 'quickstart guide' was not making any sense to me. After trying a few things and browsing through the documentation I decided that Laravel was out of my league and let it rest for the time being.

Not for long though. With fresh energy I started to look for the missing piece and hit the jackpot: http://laracasts.com, the official Laravel screencast series. I quickly spotted the 'Laravel From Scratch' mini series and was happy to see all these videos were absolutely free. That makes a lot of sense because of course you want people to get a taste of the framework. And if it works for me I should be happy to pay a buck for digging deeper. Anyway, since I didn't get anywhere at all so far I started watching the videos looking for clues on the technology that makes this thing work. After all it's just PHP. By the end of the second video I found out about the 'public' folder. I knew I was going to feel silly and sure enough. index.php lives in the public folder and the other folders should never even be accessible from the browser. From the public folder all the other stuff is pulled in behind the scenes. Now we're in business.

Laravel's command line toolbox is called Artisan and the second Laracasts video taught me how to use the 'php artisan serve' command to get this baby running without bothering with virtual hosts. Laravel's index.php is served on http://localhost:8000.

php artisan serve


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.