All Projects → benjamincrozat → lumen-boilerplate

benjamincrozat / lumen-boilerplate

Licence: other
Opinionated way to start a new Lumen project.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to lumen-boilerplate

Lumen Api Oauth
A RESTful API based on Lumen micro-framework with OAuth2.
Stars: ✭ 73 (+265%)
Mutual labels:  lumen, restful
FluentSimulator
A fluent syntax .NET REST/HTTP API simulator for automated unit and UI testing.
Stars: ✭ 23 (+15%)
Mutual labels:  restful
SLazeKit
SLazeKit is a framework providing models mapper and CoreData serializer for RESTful resources.
Stars: ✭ 23 (+15%)
Mutual labels:  restful
sns-laravel
A library to enable sending and receiving broadcasts to and from SNS topics in Laravel and Lumen.
Stars: ✭ 23 (+15%)
Mutual labels:  lumen
fintech
python fintech docs
Stars: ✭ 20 (+0%)
Mutual labels:  restful
OkSimple
OkSimple :powerful and simple okhttp network library
Stars: ✭ 57 (+185%)
Mutual labels:  restful
alipay
laravel lumen alipay 最简单,最安全,无验签,支付宝转账支付
Stars: ✭ 18 (-10%)
Mutual labels:  lumen
rentnride
Rent&Ride is an open source for Car Rental script. Travel to any of your favourite places by availing the services in the Rent & Ride application. Book cars for rental by making use of the flexibility to choose the car of your interest.
Stars: ✭ 37 (+85%)
Mutual labels:  lumen
rusqbin
A server that stashes your requests for later retrieval so you can do end-to-end testing of code that makes HTTP calls. Available as a binary, a Docker image, and a library.
Stars: ✭ 25 (+25%)
Mutual labels:  restful
lumen-file-manager
File manager module for the Lumen PHP framework.
Stars: ✭ 40 (+100%)
Mutual labels:  lumen
java-crud-api
No description or website provided.
Stars: ✭ 24 (+20%)
Mutual labels:  restful
Laravel-Auto-Hard-Deleter
Laravel and Lumen Auto Hard Deleter
Stars: ✭ 34 (+70%)
Mutual labels:  lumen
koa-better-router
❤️ Stable and lovely router for `koa`, using `path-match`. Foundation for building powerful, flexible and RESTful APIs easily.
Stars: ✭ 88 (+340%)
Mutual labels:  restful
baserepo
Base repository
Stars: ✭ 71 (+255%)
Mutual labels:  lumen
laravel-web-logs
View Laravel File-Based Logs In Web
Stars: ✭ 162 (+710%)
Mutual labels:  lumen
Spring-Boot-2
Spring Boot 2.x examples
Stars: ✭ 33 (+65%)
Mutual labels:  restful
restofus
Restofus - a cross-platform (REST) API client.
Stars: ✭ 18 (-10%)
Mutual labels:  restful
lumen-api-starter
A starter project to develop API with Lumen 8.*
Stars: ✭ 42 (+110%)
Mutual labels:  lumen
koa-restful-boilerplate
A boilerplate for koa2 RESTful API development
Stars: ✭ 31 (+55%)
Mutual labels:  restful
seal
django-base-templates 主要为 django 开发DEMO, 支持 非前后端分离 和 前后端分离模式 。
Stars: ✭ 118 (+490%)
Mutual labels:  restful

Build Status Latest Stable Version Total Downloads License

Lumen Boilerplate

Opinionated way to start a new Lumen project.

I also have an opionionated Laravel Boilerplate repository.

Summary

Why?

Lumen is a very lightweight version of Laravel. Even if Taylor managed to keep a lot of things for real world needs, it's still too light to me. Here is a list of useful packages I added to the project:

Usage

Lumen Boilerplate comes with Laravel Homestead and Vessel support out of the box, but you are free to run it in whatever environment you wish.

If you are familiar with Lumen, let's create a new project via Composer (if not, just read the documentation):

composer create-project benjamincrozat/lumen-boilerplate example

Set up your .env file. The php artisan key:generate command isn't available in Lumen, but you can just do:

php artisan tinker

Psy Shell
>>> 'base64:' . base64_encode(Illuminate\Encryption\Encrypter::generateKey(config('app.cipher')))
=> "base64:6D+I2mFMJHdw0VRDamdcy0XrgUGdHiv7ALd1+aKDmhc="

Then, run your migrations. You can even seed some fake data for users:

php artisan migrate --seed

You can also use Tinker to quickly get an API token...

php artisan tinker

Psy Shell
>>> App\User::first()->api_token
=> "fIj2rTFTWbB2UO2ZrVhEdHhLMV1XNLgHGzIMZk5FlRqww4tP2y0yyWCktTfg"

... and send your first GET request to http://example.test/api/v1/user:

curl --request GET http://example.test/api/v1/user?api_token=fIj2rTFTWbB2UO2ZrVhEdHhLMV1XNLgHGzIMZk5FlRqww4tP2y0yyWCktTfg

{
    "data": {
        "id": 1,
        "name": "Mr. Kamron Toy",
        "email": "[email protected]"
    }
}

Sample code

Lumen Boilerplate integrates basic CRUD for blog posts, integration tests and sample files that can be quickly duplicated and changed for whatever you want to build. The code is IDE-friendly and as clean and comprehensive as I can. Note that type-hinting is used only when needed, because it adds runtime checks.

Testing

It's probably a good idea to test your code. Lumen Boilerplate comes with tests to show you the way.

# Run all tests.
php vendor/bin/phpunit

# Run only unit tests.
php vendor/bin/phpunit --testsuite Unit

# Run only integration tests.
php vendor/bin/phpunit --testsuite Integration

# Run only tests within a given file.
php vendor/bin/phpunit tests/Integration/UserControllerTest.php

# Run only a given test method.
php vendor/bin/phpunit --filter user_can_read_his_own_data

# You can also do both.
php vendor/bin/phpunit tests/Integration/UserControllerTest.php --filter user_can_read_his_own_data

Here are some of my thoughts on testing:

  • Unit Tests don't ensure a working API. Good Integration Tests make your API a hell lot more reliable and you don't have to switch back and forth between your code and a HTTP client;
  • Be exhaustive. Test your validations rules, permissions, JSON structure, etc.
  • I recommend to use Facades inside your tests to make mocking and team work smoother.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].