Skip to content

huangfeng/laravel-restful

 
 

Repository files navigation

Laravel Restul with AngularJS

Backend Application

Make sure to install:

<VirtualHost *:80>  
    ServerAdmin [email protected]  
    DocumentRoot "/projects/laravel-restful/public"  
    ServerName api.dev  
    ServerAlias www.api.dev
    <Directory "/projects/laravel-restful/public">  
        Options Indexes FollowSymLinks MultiViews  
        AllowOverride All  
        Order allow,deny  
        Allow from all  
    </Directory>  
    ErrorLog "/private/var/log/apache2/api.dev-error_log"  
    CustomLog "/private/var/log/apache2/api.dev-access_log" common  
</VirtualHost>  
  • add the local host to /etc/hosts e.g.: 127.0.0.1 api.dev www.api.dev

  • make sure root folder is owned by apache2 user / group

  • make sure /app/storage folder is writable to web server user / group

  • go to app/config $ cp database.php.example database.php

  • edit the database configuration file, and fill up the password for mysql entry

  • create database called api_db in your local mysql server

  • make sure your php uses mysqlnd as mysql driver (laravel DB::raw requires it)

  • create a file bootstrap/env.php and return the environment name if its not a production environment

  • run migration $ php artisan migrate

  • run seeds $ php artisan db:seed

Javascript Single Page Application

A javascript single page application (SPA).

Stack

  • NodeJS for development platform
  • GruntJS for tooling
  • JSHint for code quality
  • LESS for CSS preprocessor and framework
  • Bower for package management
    • JQuery for DOM helper
    • UnderscoreJS for utility helper
    • AngularJS for MVW framework
    • RequireJS for module loader

Setting Up

  • Install NodeJS and NPM - (http://www.nodejs.org)
  • Install LESS
    $ sudo npm install -g less
  • Install Bower
    $ sudo npm install -g bower
  • Install grunt-cli
    $ sudo npm install -g grunt-cli
    $ sudo npm install -g grunt-init
  • Install Node modules dependencies from package.json $ npm install
  • Install components dependencies from components.json
    $ bower install
    Note: if you're running trouble installing, try with sudo and --allow-root option

Run application

$ grunt run

Misc

  • Updating composer packages without memory limit
    $ php -d memory_limit=-1 /usr/local/bin/composer update
  • Remove migration
    ``
    I did not run (php artisan migrate) the migration, so I decided to remove it. My steps:
  • Manually delete the migration file under app/database/migrations/my_migration_file_name.php
  • Reset the composer autoload files: composer dump-autoload
  • Relax

If you did run the migration (php artisan migrate), you may do this:

  • Manually delete the migration file under app/database/migrations/my_migration_file_name.php
  • Reset the composer autoload files: composer dump-autoload
  • Modify your database: Remove the last entry from the migrations table ``

About

Skeleton for creating RESTful API on PHP laravel 4 framework and AngularJS

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published