Yet another

laravel journey

16/11/14 blade , templates

Flexible blade setup

Once you have noticed the breeze the blade templating engine will bring into your templates, it’s about time to share a flexible template setup. I’ll share mine below but it’s by far the best setup in every situation.

Our file structure:

- master.blade.php

- header.blade.php
- menu.blade.php

- page1.blade.php
- page2.blade.php

Continue reading

0 likes no responses
16/11/14 installation , laravel 5

Installing latest Laravel (development) release

I’ve been experimenting with Laravel 5.x lately to get up to speed with the latest stuff being released. This is how to start a new project with the latest development version:

composer create-project laravel/laravel app-name dev-develop
0 likes no responses
16/11/14 AMPPS , error

Unable to change PHP version in AMPPS

Lately I switched from MAMP to AMPPS but I’m still a bit unsure if that was the right move. I got a bit tired with the MAMP interface and not having an easy softaculous installer for testing, though things worked perfect. Today I finally was able to solve a problem I was having with AMPPS for the last few weeks, I was unable to change the PHP version although all settings were fine. Typing this inside the terminal temporarily fixes it:

cd /Applications/AMPPS 

0 likes no responses
16/11/14 homestead , vagrant , virtual machine

Add new site to homestead (vagrant)

Like we have done before adding a new site is super easy. Just edit the homestead.yaml file and add a new site:

    - map:
      to: /home/vagrant/Code/site1/public
    - map:
      to: /home/vagrant/Code/site2/public

Continue reading

0 likes no responses
16/11/14 blade , laravel 5 , templates

Laravel Blade templates

If you have never worked with a templating engine it’s about time you open the door to let a breeze run through your projects! I’m sure you will be amazed about how easy Blade will be to use as well as how clean your templates will look. Sharpen your Blades, here we go!

This is what my controller function would look like, it’s called from the routes file and will make sure our application has maximum flexibility.

public function view() {
    $data['title'] = 'Titel pagina';
    $data['subtitle'] = 'Subtitel pagina';
    $data['random'] = rand(1,3);
    $data['loop'] = ['<em>Item 1</em>', '<i>Item 2</i>', '<b>Item 3</b>'];
    $data['users'] = [];
    return view('pages.example', $data);

Continue reading

0 likes no responses
14/11/14 error , laravel 5

Custom ‘Not found HTTP exception’

When you start doing routing and add some rules, in the beginning it’s easy to make a lot of mistakes. Because I didn’t want others to see the output laravel throws on the screen I decided to start looking for a solution to add custom error pages. In Laravel 5 you can get this done by going into app- Http - Kernel.php.

Here you should add the following to make sure the right class is called and a Response object can be made.

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Response;

Continue reading

0 likes no responses
14/11/14 error , homestead , laravel 5 , vagrant

Vagrant timeouts

Ever since I upgraded my virtualbox I was having issues with vagrant when I returned from standby. The pages I was trying to load kept going until they gave me a gateway timeout.

The following command seems to solve the virtualbox issue and will ensure your vagrant box will be running better then ever after a return from standby!

sudo launchctl load /Library/LaunchDaemons/org.virtualbox.startup.plist

Continue reading

0 likes no responses
14/11/14 laravel 5 , routing

Laravel routing

Most, if not all, routing will be done inside the app/routes.php file. Here you’ll already find a very basic example which will be called to view the first template, I’ve extended mine with a few others to experiment a bit.

$router->get('/about', 'PagesController@about');

Continue reading

0 likes no responses
11/11/14 vagrant

Vagrant commands

Since installing vagrant I’ve took some time to experiment with these commands, here are the most important ones I’ve come across.

vagrant up
This will start the vagrant server as well as resume the environment in which you want to start working.

Continue reading

0 likes no responses
11/11/14 homestead , vagrant , virtual machine

Setting up a virtual machine for laravel

What we would need for this to work:

Both VirtualBox and Vagrant are software packages which will provide us with some easy-to-use installers which can install all popular operating systems. Once installed you can add a laravel/homestead box to you Vagrant install which might take up to 10 minutes to get ready.

vagrant box add laravel/homestead

Continue reading

0 likes no responses