Showing posts with label laravel. Show all posts
Showing posts with label laravel. Show all posts

Jan 11, 2018

Useful projects to check out (2017 collection)

I have been building a list of projects and packages to check out throughout last year and I decided to consolidate them as a post.

Laravel


  • Laravel Auditing will track changes to Eloquent models
  • Ziggy is a laravel package that outputs router information in JSON form
  • Ardent, a Laravel Model extension

PHP

Vue.js

  • vue-good-wizard is a simple step-by-step wizard plugin
  • vue-directive-tooltip is a simple tooltip plugin

SSL

Postgresql

  • pgBackRest - Back-up
  • Plogical - replication 



Oct 8, 2013

Laravel 4: Setting up and basics

This guide will go through one method of setting up a basic Laravel 4 environment. There are quick-start instructions, however in this guide we are not going to rely on a pre-installed global Composer binary.

These instructions require that you have git installed.

Installation

  1. Clone the laravel framework repository. This contains a basic layout for an application, although composer will be required to install all the dependencies.

    git clone https://github.com/laravel/laravel.git
  2. Rename the directory to one more suited for your project

    mv laravel/ [project]
  3. Change the permissions and owner of your project

    chown -R [user]:[group] [project]
  4. Go into your project directory

    cd [project]
  5. Download a copy of composer for your project

    curl -sS https://getcomposer.org/installer | php
  6. Since composer will now handle all dependancies, we no longer need git to mirror the laravel repository. Remove it:

    git remote -vgit remote rm origin
    If you wish to keep the repository around, you should just rename it:

    git remote rename origin laravel
  7. Edit your composer dependencies, which are stored in composer.json. If nothing else, edit the name, description, keywords, and license fields to suit your project.
  8. Ensure your composer.json is valid by running:

    php composer.phar validate
  9. Install all dependancies via composer

    php composer.phar install
  10. Run the in-built PHP development server to check that everything is working correctly

    php artisan server

    You should now be able to view your new application through http://localhost:8000/. Use the --help flag to see more configuration options.
  11. If you make changes to your composer dependancies, just run:

    php composer.phar update

Netbeans and Laravel set-up

  1. Follow the above instructions to create a new instance of Laravel
  2. Start a new project by clicking on File -> New Project
  3. Select PHP -> PHP Application  with existing sources
  4. Select the sources folder as the project directory you created earlier
  5. Set the 'Run As' configuration as PHP Built-in Web Server with the router script set to public/index.php. Note that other files (such as css and js files) stored in the public directory will not be served.

Eclipse and Laravel set-up

  1. Ensure you have installed the PHP development extensions
  2. Select File -> New Project -> Project
  3. Select PHP -> PHP Project
  4. Enter in a project name and choose the existing source folder. You can finish the settings now, or configure the project further.
  5. I could not get the Eclipse PHP server to work, so you will have to figure that one our for yourself.

Composer overview

  • The command php composer.phar will list all the available commands in composer
  • The composer.json file will list dependencies and configuration defaults for the composer binary.
  • The composer.lock file is generated after you run the install or update composer command. This file will store the exact version downloaded and any local configuration.

Resources

May 15, 2013

Git: Pulling a single directory only from a remote repository

I was working with a web application that used the Laravel framework and, because big projects take time, the framework was updated mid-project. I wanted to use these updates without messing up the changes I had already made to config files. So I came up with this workaround:

git checkout laravel/master -- laravel/

So in detail, I run the 'git checkout' command with the parameter 'laravel/master'. That parameter is a reference to the remote repository 'laravel' (which I had set up earlier by running 'git remote add laravel git://github.com/laravel/laravel.git') and specifically the 'master' branch. The '--' in the command means I want to check-out a specific file or directory, which in this case means the 'laravel/' directory.

Nice, short and sweet.


Feb 4, 2013

Laravel: Passing parameters to Controllers and Routers

The basic idea is that you want to pass some parameters to your Laravel router so it can do some preprocessing, and then pass the rest of the parameters to the controller.

To get this happening you need to remember that when registering a route in application/routes.php Laravel captures any wildcards as parameters for the function you are registering. This can either be the controller or a custom function that you are registering. You can also call any action from a controller using the Controller::call() interface.

Putting all this together yields:
Route::get('(:any)/welcome/(:any)', function($client, $action)
{
    print($client . "\n");
    return Controller::call('home@index',array($action));
});

The first line of code is the registration function for Router, and we use the (:any) wildcard to capture almost any alpha-numeric character. The function declaration takes two parameters that Laravel fills with our wildcards (NOTE: Laravel uses positional parameters so the first wildcard will take the first variable, and so on).

The second line just prints out our first positional parameter.

The third line runs Index action of the Home controller, passing our second wildcard as it's parameter.

And that's pretty much it. Simple!