03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Embedded Systems<br />

What do you think of when you hear the name Laravel? Laravel 4 powers an increasing number of<br />

websites, but that’s not the only place it can be used. In this tutorial we’re going to use it to control<br />

embedded systems.<br />

.<br />

The code for this chapter can be found at: https://github.com/formativ/tutorial-laravel-4-<br />

embedded-systems.<br />

Gathering Parts<br />

This tutorial demonstrates the use of an Arduino and a web cam. There are other smaller parts,<br />

but these are the main ones. The Arduino needs firmata installed (explained later) and the webcam<br />

needs to be compatible with Linux and Motion (installed later).<br />

We will go over using things like LEDs and resisters, but none of those are particularly important.<br />

We will also go over using servos and these are important. You can find the bracket I use at:<br />

https://www.sparkfun.com/products/10335 and the servos I use at: https://www.sparkfun.com/products/9065.<br />

You can get these parts, and an Arduino Uno, for less than $55.<br />

Installing Dependencies<br />

We’re developing a Laravel 4 application which has lots of server-side aspects; but there’s also an<br />

interactive interface. There be scripts!<br />

For this; we’re using Bootstrap and jQuery. Download Bootstrap at: http://getbootstrap.com/ and<br />

unpack it into your public folder. Where you put the individual files makes little difference, but I<br />

have put the scripts in public/js, the stylesheets in public/css and the fonts in public/fonts. Where<br />

you see those paths in my source code; you should substitute them with your own.<br />

Next up, download jQuery at: http://jquery.com/download/ and unpack it into your public folder.<br />

For the server-side portion of dependencies, we need to download a library called Ratchet. I’ll explain<br />

it shortly, but in the meantime we need to add it to our composer.json file:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!