Skip to content

Restler 3: Using it with Laravel's structure and Database

Arul edited this page Feb 4, 2015 · 1 revision

We will be using composer for gathering all the required source code and put them together.

You can learn about composer at https://getcomposer.org/doc/00-intro.md#globally follow the steps there to get composer installed globally.

I'm assuming the project name as api use your own name of choice instead.

Once done you should be able to run composer on terminal from any folder. Now run the following

composer create-project laravel/database --prefer-dist api

create-project

Lets add restler to this project

cd api
composer require restler/framework 3.0.0-RC6

require-restler

you may want to look at the composer.json to understand how a specific version of a package can be requested

Ignore the suggestions, we surely don't need explorer from external package. It is part of restler now!

Folder structure will be familiar to you if you have used larvavel before. folder-structure

  1. Copy your api files in to app/controllers folder

  2. Look at the public/index.php and uncomment the lines related to restler public-index

  3. Add your own api classes along with existing 'Explorer', and do all other customisations needed.

  4. Make sure app/store and all the folders inside are writable

     chmod -R 0755 app/storage
    
  5. Test the app using php built in server php artisan serve artisan-serve

Now you can point your browser to http://localhost:8000 to test your application. http://localhost:8000/explorer/ has the brand new explorer as well!

You can create your own database models and place them in app/models or simply use DB::table('name')->where... style queries. You can refer to laravel documentation for more info

All database related stuff that you used to do in artisan are now available for your project! we have added few more too! check them out and have fun!