prusmarcin/laravel-rest-server

Package Rest Full Server for Laravel 5.6

dev-master 2018-04-10 16:27 UTC

This package is not auto-updated.

Last update: 2024-04-18 09:32:14 UTC


README

Package Rest Full API server for Laravel

You can see package Client API package laravel-rest-client for use on a separate Laravel installation

Total Downloads Latest Stable Version License

Installation

To install this package you will need:

Laravel 5 (see compatibility table)
PHP 7.0 +

Install via composer - edit your composer.json to require the package.

{
    "require": {
        "prusmarcin/laravel-rest-server": "dev-master"
    }
}

Then run composer update in your terminal to pull it in.

Or via the command line in the root of your application installation.

$ composer require prusmarcin/laravel-rest-server

Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:

\Restserver\RestserverServiceProvider::class,

And configure the database connection in .env file for your Laravel installation.

Run migration

$ php artisan migrate

Note: If you have error when you run migration: "Specified key was too long error solution". Read this article: https://geektnt.com/laravel-5-4-migration-unique-key-is-too-long.html

Run seeder

$ php artisan db:seed --class=Restserver\\Seeds\\DatabaseSeeder

Run laravel server

$ php artisan serve

And you're done!

Usage

http://localhost:8000/api/items/available

Returns

[{"id":5,"name":"Produkt 8","amount":2},{"id":4,"name":"Produkt 7","amount":6},{"id":2,"name":"Produkt 2","amount":12},{"id":1,"name":"Produkt 1","amount":4}]

More methods: Screenshot

Testing

Run laravel server

$ php artisan serve

Then run the tests with:

$ vendor/bin/phpunit vendor/prusmarcin/laravel-rest-server

Author

License

The MIT License (MIT). Please see License File for more information.