Lime Blast » PHP http://limeblast.co.uk The virtual home of Web developer Daniel Hollands, the place to be if you're looking for articles and tutorials (and rants) on all aspects of the World Wide Web. Wed, 14 Oct 2015 13:13:21 +0000 en-US hourly 1 http://wordpress.org/?v=3.9 Laravel Application Development Cookbook /2014/01/laravel-application-development-cookbook/ /2014/01/laravel-application-development-cookbook/#comments Mon, 13 Jan 2014 20:00:21 +0000 /?p=1152

Related posts:

  1. Useful Composer packages for use with Laravel 4By this time next week, I would have (hopefully) survived my first day at my new job, and gone back for more. My new job requires that I learn Yii, which I have been doing, and for the most part......
  2. Web Developer Economics: One Off Software CostsTaking inspiration from a post by Chris Coyer on Web Developer Economics, specifically that of One Off Software Costs I’ve decided to put together my own list of figures. Unlike Chris however, who had a start up cost of $1,779.98, I......
]]>

Introduction

At the tail end of October last year I saw a post on LinkedIn by Packt asking if anyone would like a free copy of their recently published Laravel Application Development Cookbook by Terry Matula. Being the greedy so-and-so that I am, I jumped at the chance to get something for free – the fact it was a book about Laravel, a framework which is currently in the centre of my latest project, made it all the sweeter. Of course, there is no such thing as a free lunch, and in exchange for the aforementioned free copy of the book, I had to write a review of it, which is what you’re reading right now.

I should mention at this point that I’ve only read the first three chapters, so there might be a second or even third part to this review published at some point in the future, but I feel that I’ve read enough (and seen enough warning signs in the way that the book is written) to give my opinion on what I have read thus far.

Laravel

Laravel, for anyone that doesn’t know, is a PHP framework developed by Taylor Otwell and popularized by Jeffrey Way (at least, it’s because of Jeffrey Way that I know about it). Taking advantage of the latest features available in PHP’s arsenal, not least of which being Composer, a dependency manager which takes the hard work out of using third-party classes, Laravel is at the cutting edge of what PHP can do.

One of the things that I like about Laravel is that anyone with experience writing PHP can pick it up and use it with ease. That’s not to say there isn’t anything to learn about the framework (there is a hell of a lot), rather, whereas Frameworks like CakePHP and Yii have their own, propriety and overly complicated ways of going about thing such as using modules/addons/packages/classes, the PSR standards which Laravel adopts (thanks, in part, to Composer) are super simple. Combine that with a whole host of cool ideas and features, and you’ve got yourself a fantastic little framework.

The Book

Unfortunately, while I would love to sing this book’s praises, I found too many examples of sloppy code and poor explanation within the first three chapters to do this.

An example of this, early in the first chapter, is the task titled “Installing Laravel as a git submodule”. While I can’t fault the method presented within the book for achieving this, I’m a little confused as to why this task even exists, as frankly, it’s just a bad idea. The Laravel framework itself is a Composer package, and is both installed and autoloaded via it, so to ignore this system in favour of a git-based one, which would make updating it much more of a chore, just doesn’t make sense. If this book was for a framework like Yii, then it would be a perfect fit, and I’d be applauding it for including it, but here, it just leaves me with the impression that the author doesn’t understand Laravel.

The next task, designed to help you set-up a working server environment, is no better. Here the author knows that PHP has a built-in server, but rather than teach you how to use it, instead focuses on setting up a full stack environment. OK, so I don’t really have a problem with this in itself, but I do have a problem with the approach he takes, specifically that of recommending wampserver. For what it’s worth, as a Windows user, I like wampserver, and have been known to use it from time to time. The problem with wampserver is that it only works on Windows, and the author fails to provide Mac or Linux users with any useful information on how to do the same on their respective platforms.

The other problem I have with this approach is that a better alternative exists, that of Vagrant, a cross-platform solution that makes it easy to create virtual machines running whatever server software you need. You don’t even need to worry about learning how to configure Vagrant or the virtual machines it hosts, as tools such as puphpet, or pre-configured systems like Laravel4-Vagrant make it easy.

The next few tasks and following chapter were better, with some useful information, although none of it was ground-breaking, and most of it I already knew from other sources. I was disappointed that none of the examples I’ve read so far included anything about Blade (Laravel’s template system), although this could have been to try and keep examples simple (not that Blade is complicated).

Conclusion

Now maybe I’m being unfair in this, seeing as I have only read about a quarter of the book, but based on what I have read, I’m not filled with confidence in the quality of what lies ahead, (this is partly why I have only read three chapters). It is for this reason which I’m finding it difficult to recommend this book. I do plan on finishing it, as it will no doubt have some useful information, and parts two and three of this review (if they ever get written) might contradict this opinion, but until that happens, I’d say borrow the book from a friend rather than pay for it yourself.

In the meantime, if you’re looking for a good way of learning Laravel, you can’t go wrong with Laracasts.

]]>
/2014/01/laravel-application-development-cookbook/feed/ 0
Useful Composer packages for use with Laravel 4 /2013/07/useful-composer-packages-for-use-with-laravel-4/ /2013/07/useful-composer-packages-for-use-with-laravel-4/#comments Tue, 16 Jul 2013 12:33:25 +0000 /?p=1119

Related posts:

  1. I love you Jose Diaz-GonzalezThis is a very quick post to thank Jose Diaz-Gonzalez for the Upload behaviour he wrote for CakePHP. I needed a way of uploading multiple images in the admin area of the Chameleon Photography site. During my Cake 1.3 days,......
  2. How to use Couch CMS with GitAfter around a year of using WordPress for the majority of the websites I built for Ghost, I was looking for something different. That isn’t to say that WordPress is bad – it isn’t – it’s just that for some......
  3. CSS CrushAlthough there is a lot of love for CSS preprocessors such as LESS and SASS, both of which seem to work very well, I wanted to take a moment to talk about a slightly different alternative, the PHP-based CSS Crush. Much......
]]>
By this time next week, I would have (hopefully) survived my first day at my new job, and gone back for more. My new job requires that I learn Yii, which I have been doing, and for the most part have found to be a perfectly suitable framework for dependable web apps…

..but I would be lying if I didn’t admit to flirting with the sexy new framework going by the name of Laravel 4.

Laravel?

I first learnt of Laravel by reading articles published by Jeffrey Way in Web Designer magazine. It is a framework which takes advantage of the latest developments in PHP (such as Composer), and makes building sites more.. well.. fun!

This isn’t a post about explaining how great Laravel is however (I’ll let Jeffrey do that). Rather, this is a post, primarily aimed at myself, to list all the useful composer packages which I’ve found during my time learning the framework, and as I’m still learning the framework, as I find new and existing packages, I’ll try to keep this post updated accordingly.

Packages I’ve used

JeffreyWay/Laravel-4-Generators

This is the first of three packages created by Jeffrey Way which I’m going to recommend. It builds upon Artisan by adding a number code generation tasks to it. One of the things I liked about CakePHP (back in 2006) was it’s Bake feature – and this is the closest thing I’ve found to it in any framework (although, I have seen that Yii also offers something similar).

JeffreyWay/Laravel-Guard

I’ve been a fan of Guard since I discovered it’s ability to automate a large amount of your workflow simply by watching for file changes and acting accordingly, i.e. you can set it to automatically compile Sass files before livereload‘ing your screen. This package makes the process of configuring Guard for use with Laravel really simple.

JeffreyWay/Laravel-Test-Helpers

I don’t know much about Test Driven Development, but I’m currently learning how to do it (thanks, once again, to Jeffrey Way), and I know enough to make me want to use the technique for everything I build. This package helps simplify the process by offering a number of shortcut methods for the tasks you’re most  likely to do.

barryvdh/laravel-ide-helper

Although I’ve been trying to get into the flow of using Sublime Text 2 for coding, I keep reverting back to PHPStorm for a number of it’s features, one of which being code autocompletion. The problem I’ve found, however, Laravel’s facades paradigm prevents this from working out of the box. This package seeks to rectify this problem by creating  a docblock helper file which the IDE can take cues from.

Packages I’ve not used… yet

…and more can be found at the Laravel Packages Registry (thanks Luke).

(Featured image by rafdesign)

]]>
/2013/07/useful-composer-packages-for-use-with-laravel-4/feed/ 2
Web Developer Economics: One Off Software Costs /2012/11/web-developer-economics-one-off-software-costs/ /2012/11/web-developer-economics-one-off-software-costs/#comments Fri, 02 Nov 2012 12:32:53 +0000 /?p=756

Related posts:

  1. Running a server is hard workI was hoping, when I first had the idea for this post, that it would be a run-through of all the steps I has taken in setting up my dedicated server. It was going to include links to the resources......
  2. The Lone Developer Article (Published in Full)Back in late January, after spotting an advert on Facebook, I contacted .net magazine with an idea for an article on the challenges faced by lone developers. Within one hour I’d received a reply from their deputy editor, Tom May, giving me the......
  3. CSS CrushAlthough there is a lot of love for CSS preprocessors such as LESS and SASS, both of which seem to work very well, I wanted to take a moment to talk about a slightly different alternative, the PHP-based CSS Crush. Much......
]]>
Taking inspiration from a post by Chris Coyer on Web Developer Economics, specifically that of One Off Software Costs I’ve decided to put together my own list of figures. Unlike Chris however, who had a start up cost of $1,779.98, I think you’ll find my costs are far lower.

Essentials

These are the applications and software without which I would be unable to do my job.

NetBeans (Free / Open Source)

Having tried a number of different text editors over the years (including PSPad and NotePad++) I’ve settled upon NetBeans as my editor of choice. Netbeans, being an IDE however, is more than just a text editor, and while I have to admit that I probably don’t use anywhere close to all its tools and features, the tools and features that I do use (PHP syntax checking, Git diff highlighting, syntax autocomplete, source formatting, et al) are invaluable.

VirtualBox (Free / Open Source)

A valuable piece of software that lets me run guest operating systems on my PC. My initial reason for using this was to run copies of Windows XP (for IE6), and Windows Vista (for IE7 and IE8) for backwards compatibility testing of Web sites, but in recent months I’ve started using it to run a LAMP development server.

Debian (Free / Open Source)

Used as operating system, this is the L of the aforementioned LAMP development server. There seem to be as many different flavours of Linux as there are religions (and their followers are just as ferocious), but current poster child is Ubuntu, which is built upon best practice and designed to make things as easy as possible. I’ve chosen Debian however, as I’m new to managing a Linux server, so wanted to learn best practice for myself, rather than have it all done for me.

Apache, MySQL and PHP (Free / Open Source)

With the first letter of the LAMP abbreviation being filled by Debian above, the last three are filled by Apache (a web server), MySQL (a database) and PHP (a scripting language), which combined, power most of the Web sites I build.

SASS (Free / Open Source)

SASS is a CSS preprocessor written in Ruby which “makes CSS fun again”. It does this by adding a number of features sorely missing in vanilla CSS, including support for variables, calculations, functions and mixins. SASS files need to be compiled before they can be used, but this is handled by running a simple script on the command-line which does this automatically every time they’re saved.

FileZilla (Free / Open Source)

Although I use Git to deploy my sites, no web developer can survive without an FTP client, a piece of software that allows me to transfer files between two computers, such as the local machine and a server.

PuTTY (Free / Open Source)

This is an SSH client which allows me access to the command line of my remote servers. Nuff said.

KeePass (Free / Open Source)

As I mentioned in my article on the importance of a good password, in addition to keeping a secure copy of all my own login details, I have a duty to do the same for the login details of my clients. KeePass, an encrypted password manager makes this easy.

Optional

Although not needed to do my job, this list of software and applications which do make my job easier.

Synergy (Free / Donationware)

I work in an office full of iMacs (my own personal hell) and was given an iMac of my very own to use (f7u12) – so from my second day of working here I brought in my own Windows 7 laptop to use instead. Quickly realizing the benefits of being able to use two separate machines simultaneously however, lead me to Synergy: an application which allows me to share the keyboard and mouse of my Windows 7 machine with the iMac via the network.

DisplayFusion ($25)

Thats right, I’ve actually paid for something… Much like the aforementioned benefits surrounding the use of two separate computers, as a result of working for Propeller I discovered the benefits of having multiple monitors on a single computer. At a minimum DisplayFusion adds a taskbar to the second monitor, but also makes it easy to setup multi-monitor wallpapers, window snapping, and buttons which send the applications to the other monitor.

Conclusion

Wow, so while Chris’ one off costs amount to $1,779.98, mine are a fraction of that at $25 (and even that is optional extra).

By now however, I’m sure that many of you will be painfully aware that I’ve neglected to list Creative Suite (or even one of the many free alternatives such as GIMP or Pixlr) which accounted for $1,299 of Chris’ budget. This is because, as a developer (rather than a designer), I don’t actually have to do all that much image manipulation. What little I do do is limited to basic stuff like image cropping and sharpening, for which I do use Photoshop (a cost of $699, which thankfully has been absorbed by my various employers), but could just as easily do this using either of the free options listed above.

But even removing this from the equation only reduces Chris’ budget to $480.98, which is still   almost 20 times higher than mine. And it’s not even like I’m missing out on anything. I’m able to do my job as efficiently and comfortably as he does his.

Anyway, the next post in this series will be in response to Chris’ Monthly Service Costs – watch this space.

]]>
/2012/11/web-developer-economics-one-off-software-costs/feed/ 1
CSS Crush /2012/04/css-crush/ /2012/04/css-crush/#comments Thu, 05 Apr 2012 14:00:57 +0000 /?p=312

Related posts:

  1. Facebook Timeline Photoshop TemplateSeeing as Facebook’s Timeline feature is making the move to Pages, I figured that now was a good time to share the Facebook Timeline Hack Template that I used to style up my Timeline Page. The download includes a Photoshop......
  2. Images in responsive WordPress Web sitesFor the past couple of weeks I’ve been learning how to build responsive Web sites, a process that is simple in principle, but complex in practice once you get down to the nitty-gritty. As I want to use this blog as......
  3. Running a server is hard workI was hoping, when I first had the idea for this post, that it would be a run-through of all the steps I has taken in setting up my dedicated server. It was going to include links to the resources......
]]>
Although there is a lot of love for CSS preprocessors such as LESS and SASS, both of which seem to work very well, I wanted to take a moment to talk about a slightly different alternative, the PHP-based CSS Crush.

Much like the other CSS preprocessors, CSS Crush offers a range of features designed to make your life easier. Although these including functions that let you do things like manipulate the opacity of a colour value, or generate a data uri from a relative file path, I’m going to talk about some of the other features that I have experience with.

Vendor prefixing

The first, and possibly most important of these, is vendor prefixing. There has been a lot of talk in recent months about non-webkit browsers adopting the -webkit prefix, which has been spurred on by the fact that, to be honest, vendor prefixes are a pain in the arse.

CSS Crush helps solve issues like this by automatically adding all relevant prefixes to the properties that support them, meaning that this:

div { background: #fff linear-gradient( left, red, white ) no-repeat; }

will automatically be converted into this:

div {
    background: #fff -webkit-linear-gradient( left, red, white ) no-repeat;
    background: #fff -moz-linear-gradient( left, red, white ) no-repeat;
    background: #fff -ms-linear-gradient( left, red, white ) no-repeat;
    background: #fff -o-linear-gradient( left, red, white ) no-repeat;
    background: #fff linear-gradient( left, red, white ) no-repeat;
}

This is something that (so far as I’m aware) none of the other CSS preprocessors offer out of the box – although some creative use of mixins does offer something similar – but by using CSS Crush as a git submodule, you’ll always have access to the latest prefixes available.

Variables

Another helpful feature is that of being able to define and use variables. This allows for uniformity across all your stylesheets, meaning you can define variables such as:

@define
{
	/* fonts */
	title: "Times New Roman", Georgia, serif;
	body: Verdana, Arial, Helvetica, sans-serif;

	/* colours */
	primary-rgb: 89,168,15;
	primary: rgb($(primary-rgb));
	primary-text: #FFFFFF;

	secondary-rgb: 158,213,76;
	secondary: rgb($(secondary-rgb));
	secondary-text: #FFFFFF;

	background-rgb: 240,242,221;
	background: rgb($(background-rgb));
	background-text: #222222;
}

then if you need to change a value at a later date, rather than having to do a find/replace, and risk missing some, you simply update the value is one place, and CSS Crush does the rest for you.

Direct @import and minification

One of the things I found particularly useful was the ability to use @import to manage different CSS files for responsive sites. A practical example of this would be something like:

@import url( "mobile.css" ); /* Mobile first */
@import url( "tablet.css" ) screen and (min-width: 768px); /* Tablet and higher */
@import url( "desktop.css" ) screen and (min-width: 992px); /* desktop and higher */

which not only imports the files directly into a single stylesheet, would also put the correct @media tags around the imported code, and then performs minification on it all.

Implementing CSS Crush in WordPress

I’m actually using CSS Crush in my limeBase WordPress starter theme, so that could be a good way for you to get started, but if you wanted to create your own implementation, it couldn’t be simpler:

  1. Download/clone the files into your theme folder in a folder called cssCrush
  2. in your functions.php file, add the following line
    require_once 'cssCrush/CssCrush.php';
  3. in your header.php, replace your existing stylesheet <link>code with
    <?php echo CssCrush::tag( TEMPLATEPATH.DIRECTORY_SEPARATOR.'style.css' ); ?>

Upon viewing your page, CSS Crush will create two new files: .csscrush and style.crush.css, and output the relevant <link> code linking to the new style.crush.css file.

If, before further page views, the original style.css gets updated, CSS Crush will detect the change, and generate a new crushed file for you, otherwise it will continue to serve the cached file.

Conclusion

If you’re already happily using LESS or SASS, then I’m not sure there is much that CSS Crush can offer you. If, however, you’re more interested in a simple way of automatically adding vendor prefixes and performing minification on your CSS, then you can’t go far wrong with CSS Crush.

]]>
/2012/04/css-crush/feed/ 0