It's been quite a while since my last post, but I am planning on getting back on here regularly to post more regular content. I have transferred this blog to my main email address, so there will be one less barrier to entry, hopefully.
Today, I would like to briefly touch on a PHP Framework called Laravel. Now, anyone who has been even kind of active in the PHP community has likely heard of this one, as it is perhaps one of the most popular frameworks for PHP at the present moment.
I have been looking into this framework, and learning a little bit about it in preparation for development of a side project of mine. First of all -- why Laravel? Why not CodeIgniter, or Yii, or one of the many other frameworks out there? Well, I actually did check out CodeIgniter a little bit the other day before coming across Laravel. It seemed very versatile and useful, however, it had a couple of issues which made it difficult for me to get started, and upon a little bit of searching, it looks like Laravel may be the more promising choice for potential job availability in the future.
I have begun reading through a couple learning resources regarding Laravel, and am really liking what I have seen thus far. From my brief flirtation with CodeIgniter, it seems as though routes are a common framework feature, however, I really like how clean and simple it really is to implement in Laravel. To implement a simple route, you need very little code:
Route::get('/about', function() // When the user visits the about directory of your website... { return View::make('about'); // Serve them the about page. });
I am also very impressed with the ease in which you can pull in assets. Recently I have been using the method of declaring a BASE_URL constant:
define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/SomeDevelopmentFolder/');
And declaring it contstantly:
<a href="<?php echo BASE_URL;?>folder/someresource.php">Link</a> <a href="<?php echo BASE_URL;?>folder/anotherresource.php">Link</a> <a href="<?php echo BASE_URL;?>folder/evenonemore.php">Link</a>
While I enjoy it's benefits, it gets a bit old. Laravel allows you to simply use:
<a href="{{ asset('images/image1.jpg') }}">Link</a> <a href="{{ asset('images/image2.jpg') }}">Link</a> <a href="{{ asset('images/image3.jpg') }}">Link</a>
While this may seem like a slight difference in terms of length, it sure is quite different in terms of finger movements! I am sure that I have only scratched the surface of the value of this feature of Laravel, and apologize if I have not done it justice!
On top of it all, it also comes with a very useful templating language called Blade. My experience with Blade and Laravel in general so far have been very pleasant.
I am roughly half way through a wonderful book by Jack Vo called Learning Laravel: The Easiest Way (http://learninglaravel.net/), which easily explains many of the concepts of Laravel. I actually highly recommend it, though I am not very far into it yet. It will also give you a primer on Bootstrap and a couple of other web development tools if you have not yet dabbled with them.
I plan to post again about Laravel when I have a more complete knowledge of the features and uses that it has, however, right now I do not know much more than these basic things.
Please, please, please feel free to correct me or call me on anything if it doesn't sound right, as once again I am a newbie at this big bad Laravel business. These are all of my observations while learning what I have learned, and some of them are bound to be formed in part by my relative ignorance of the true capabilities of this framework.
Again, I thank all of you who are reading this, and plan on keeping it more up to date. I plan to post at least once a week, but I want to shoot for twice. We shall see how it goes, as things have been pretty busy lately, but I will fit it in where I can, as long as I feel like I have something of relative value to post.
No comments:
Post a Comment