Laravel PHP Framework – collection of screencasts and tutorials

A little over a month ago, I started toying around with other PHP Frameworks besides my first love, CodeIgniter.  I was familiar with Kohana, because of its CI ties, and I tried out Yii and even micro-frameworks like Slim.  Then, somewhere in my Twitter stream, I came across a tutorial for Laravel from a site by Dayle Rees.  There was also talk of an impending book release based on those tutorials, and when it was released, I happily bought a copy of Code Happy.  And while it could just be effective mind-control marketing on their part, I really did find it fun to learn and code.  So the following are some tutorials that helped me along the way to learning about Laravel…

Code Happy

If you want to get up-and-running quickly, even without previous framework experience, I can’t recommend this book enough. The minimum price is $5, but if you don’t give at least $10, you’re a big, stupid jerk. Seriously. There’s already been an update to Laravel, and he updated the book almost immediately after… and once you buy it, you get the updates for free.   Beyond the fact that this is an immensely helpful book, people need to support this publishing model.

You can also find most of the material on his blog, if you want to see what you’re getting.

 

HeyBigName – Shawn McCool

He caused a bit of an “uproar” over his Codeigniter is dead post, but his Laravel tutorials are top-notch. And screencasts to boot… which are always cool. The controllers and routes tutorials are great for beginners, and get you started making sites pretty quickly. I just watched his Form Model screencast, and I’m eager to try out that bundle.

 

 

The Official Laravel Screencasts

There aren’t a whole lot of these, but they serve as a great introduction to the framework. If you want to get acquainted with the Eloquent ORM, there are some good videos… and I found the overview of the Blade templating system to be informative.

 

Jason Lewis

There’s some more overview/getting started stuff here, but also a couple of more in-depth tutorials. The Advanced Validation lesson is very nice, and is something I’ve begun to implement myself.

 

Eric Barnes

Not so much tutorials, but he blogs about Laravel and uses it for his job. I subscribe to his blog for his links to other Laravel (and Codeigniter) resources and occasional commentary.

 

The Laravel website

This is a very young framework, but the documentation is very well done and extensive. One of the reason I love PHP and Codeigniter is because they are both well documented, and if I have a question about a method, or the order of arguments for a function, I know exactly where to go.  Laravel has taken this notion to heart right from the beginning.  And if you can’t find your answer there, the forums are a great place to ask your question. In fact, the guys that did these tutorials are frequently the ones to answer questions… so you’d be getting expert advice.

 

So eventhough Laravel is probably one of the youngest PHP frameworks, it seems to be gaining a lot of steam very quickly. People love it even if they don’t plan on using it. So hopefully, this list will only expand as more people jump on board.

Links to Unemployment signup page for each state

At SXSW, I spent a couple of the days at the sessions dealing with government topics.  One of the things that was brought up quite a bit was that State websites are almost universally horrible.  They’re poorly designed and finding information easily is near impossible.  Utah is one exception to this rule, but really, it’s just about the ONLY exception.

I decided to try and find the Unemployment signup pages for a couple of states, just to see how easy or difficult it was.  It was NOT easy.  I remember a couple of years ago, when I was laid off, getting to the Texas unemployment online signup was full of twists and turns, and pages of descriptions and explanation. I just wanted to go to the signup page.  So I decided to create a simple page with links to the unemployment signup pages for each state… hopefully skipping all the explanations and description pages.

As I was searching for each state, I was surprised at how outdated the sites were. So many required Internet Explorer, and a couple prevented me from even accessing the pages using Chrome.  And Pennsylvania… Netscape Navigator? Really? Well, it IS using classic ASP… so I guess it is to be expected.

I think I may do this for other commonly needed pages, too.  In one of the sessions, someone mentioned how difficult it was to find info about building permits… but since that gets into county and city pages, it may be beyond the scope of this project. I just need to figure out what pages are most commonly needed.

7 Useful Twitter Bootstrap Resources (updated)

Twitter Bootstrap is a CSS framework that I’ve been using for all my projects recently.  It makes getting a nice looking design quick and easy.  The simplicity of it has made it possible for all sorts of resources and “hacks” to pop up.  Here are some that I’ve found…

  1. Built With Bootstrap
    A directory of sites that use Twitter Bootstrap. Many of them are easily identifiable by the grey nav bar and button styles, but some have really extended it.
  2. jQuery UI Bootstrap
    Bootstrap (especially v2) has some nice javascript included, but if you like jQuery UI and want it themed like Bootstrap, this will do it.
  3. Darkstrap theme
    If you’d prefer to have things not so “bright”, this theme will make a dark version of Bootstrap. It’s actually a separate file, so it doesn’t alter the actual Bootstrap CSS file.
  4. Bootswatch
    As of today, these are 6 nice, premade themes using altered Bootstrap.
  5. Lavish
    This is a pretty neat project.  You add in the URL for an image and it generates a color scheme for Bootstrap based on the colors in the picture.  You can get some nice results.
  6. Fbootstrapp
    A Bootstrap theme that mimics the Facebook design. It’s also designed to work really well if you develop canvas apps that will actually be viewed ON the Facebook site… keeping the design consistent. It’s still using v1.
  7. The Bootstrap customizer
    Finally, the customization page from Bootstrap. Choose only the elements you want in your CSS, change the default values, and download.

 

UPDATE ( 3/7/2012)

8. Font Awesome
“iconic font designed for use with Twitter Bootstrap”

 

 

 

Making a box “width” keep that width, even with padding.

I’m saving this Paul Irish post for later (or always) use from now on. There’s nothing worse than defining something as 400px wide with 20px padding left and right and… oh wait, NOW it’s actually 440px wide and screwing up the layout.  So if I want the box to REALLY be 400px wide, I have to define it as 360px wide… *sigh*

So here’s the code:

/* apply a natural box layout model to all elements */
* { 
    -moz-box-sizing: border-box; 
    -webkit-box-sizing: border-box; 
    box-sizing: border-box; 
}

Getting good with Linux (pt 2)

In part 1, I got Ubuntu installed and was able to connect from my Windows laptop.  Now I need to get Apache, MySQL, and PHP installed.

First, Apache.  The command to install is simple: sudo apt-get install apache2  … and a few minutes later, Apache is up and running. I put the ip address into my browser, and i got “It Works!”.  Sweet.

To get PHP working, I followed this installation guide.  The guide is more for if you are USING the machine you’re installing to, but it works over SSH.  The one extra thing I did was get into the /var/www directory… then type sudo nano test.php .  In the file I put in <?php phpinfo(); and then Ctrl-O to save it.  Then in the browser, went to http://192.168.1.6/test.php and I got the PHP configuration page.  It worked again!

I followed the install guide for MySQL, and in a couple of minutes it was done.  I kept the main user as “root” with no password, then the command “mysql -u root” got me connected with no problem.  Then there’s this handy page with lots of useful commands.

So I’m all set up.  Now, I’m wondering what to do next.  How can I transfer local files to the dev machine?  I’ve read about installing samba and then map a drive… or use git, and push it to the dev machine… or even something like Phing, which I’d need a crash course in. That’s next…

A Different Type of Resume (Résumé)

The one thing that’s difficult to tell from a programmer’s résumé is “Can they actually code?”  Sure, they may have had some coding jobs in the past, or have some schooling in programming, but that doesn’t tell you much about their actual skill.  Or maybe they DON’T have the schooling or work experience, but have done tons of personal projects or worked in open source projects… a résumé might miss that talented coder.  One of the things that I see a lot of tech people looking for recently is a Github account, and examples of coding or helping with open source projects, which is great.

As I thought about putting together a résumé, I wondered how can I demonstrate understanding of modern PHP concepts, without the hiring person needing to jump through a lot of hoops, or visit a bunch of sites.  So I created a résumé in code, and got some useful tips from the Forrst community as well.

The goal was to make a resume that could be readable to a non-programmer.  And I think if you look at it, you should be able to follow along:

$myResume->myName = “Terry Matula”;
$myResume->myEmail = “terrymatula-at-gmail-dot-com”;
$myResume->myPhone = “281-656-1474”;
// Places I’ve worked
$workExperience = array();
etc…
Even if you knew nothing about coding, that should make sense. And the great thing is, if you copy the file to a server and run it, it actually makes a somewhat nice looking résumé page.

Things I’ve Learned Using Codeigniter – PHP

1) You don’t need an ORM

I had experimented with Datamapper, and it was great. But there was complex join statement I needed that DM didn’t support… so I had to just write out the SQL like normal.  I then realized it’s just as easy to use CI’s Active Record or regular query command and create your own methods.  Plus, it keeps things pretty speedy.

2) You DO need a base Model

I’ve only just recently started using Jamie Rumbelow’s MY_Model and it’s changed everything. Previously, when I wanting to get a single record from a table, I was writing $this->db->from('table')->where('id',$id)->limit(1)->get()->row(); for every single table. Now, that’s already included for every Model I make.

3) It’s helpful to look at the core code

For example, I was curious how the Active Record was implemented, so I opened up DB_active_rec.php. I know some people prefer to use “->get()” by adding in the table name and limit as parameters, and I wondering if there was difference in how it’s handled.  Interestingly, it runs the exact same “from()” method, just as if you had “->from()” in the query.

And while this is a micro-optimization, if you want to return a single result and you’re sure it’s the first result… use “->limit(1)”.  The “row()” method will work with multiple rows returned, so there’s logic built in to just return the first row.  Adding “->limit(1)” will help skip all that.

4) The url helper really needs to be auto-loaded by default

In my autoload file, I always load the database and sessions libraries and the url helper. I can’t remember a project where those didn’t get used.  I’ll occasionally autoload the form helper as well, but that’s a project-by-project call.

But the url helper… I honestly can’t see how anyone would ever NOT use that in every project.  “site_url()” and “redirect()” just seem like no-brainers.

5) Object-Oriented programming and MVC

Prior to learning Codeigniter, I was experience in Drupal and WordPress, and a bit of Joomla, but working with them isn’t strict OO.  The custom stuff I programmed was really procedural or functional, based on the fact that I learned programming using PHP 4 and classic ASP/ vbscript.  While I read about and tried using Classes and methods, I just didn’t get it. With CI, I had the ‘flipped switch’ moment, where Objects and Classes made total sense.

Now, I’m onto learning as much as I can about OO in PHP 5.3, including namespaces and inheritance… which aren’t yet built into CI

5 Rules for Your Email List Unsubscribe Link

I put my email address into a lot of forms, especially because I like to check out new sites and services, and I’m always hoping for the “beta” invite. Inevitably, this means I also get added (without my knowing) to a lot of email lists. At the bottom of most emails is usually (if they’re following the law) a link to “unsubscribe”.  I’ve noticed some companies do unsubscribes right, and others… not so much.  So here are my rules that you should always follow for YOUR email list:

1) The best unsubscribe link takes you to a page that says “You’ve been removed from our list”… and that’s it.  Simple, effective, and I won’t hate you or your company afterwards.

2) The second best way (if you really think your email recipients are so stupid they may click it unintentionally) is to have a page with two buttons. One saying “Unsubscribe” and another saying  “Oops! I made a mistake! I don’t know how links works! Derp” or something.

3) NEVER ask for my email address to unsubscribe. You sent me the freaking email, you should KNOW my address. Also, I often use the “plus trick” for my gmail, and asking me to track down exactly what email address I used for your stupid, spammy site will just fill me rage and hatred for you and your babies.

4) NEVER send an “Unsubscribe Confirmation” email. Seriously? Are you that stupid? I just said “Don’t send me any more emails” and you’re going to do the exact opposite? How are you able to feed and clothe yourself?

5) Do NOT ask me to sign in and “change my notification preferences”. More than likely, I already forgot the password for your lame company that TechCrunch will never cover, and I’ll just have to do a “forgot password” thingy… meaning I must both find what email address I used AND get another email from you. Fail. Fail. Hatred. Fail.