Giter Club home page Giter Club logo

lumen-api-starter's Introduction

Lumen 5.8 API Starter with Paseto

Build Status

Notes

  • Comes with make & route command for all your needs
  • Uses jwt token alternative paseto. Read Paseto

Included Packages

Installation

  • run git clone [email protected]:mstaack/lumen-api-starter.git
  • reinit your repository with rm -rf .git && git init
  • run composer install to install dependencies (consider using homestead via vagrant up)
  • copy env.example to .env
  • Setup your application & auth keys with composer keys & check .envfile (automatically done via composer hook)
  • run migrations & seeders with artisan migrate --seed (within your vm using vagrant ssh)
  • A default user is created during seeding: [email protected] / password
  • To quickly start a dev server run ./artisan serve (or via homestead.test for the vm)
  • Also consider running composer meta when adding models for better autocompletion (automatically done via composer hook)
  • Run included tests with phpunit within vagrant's code directory
  • Generate your api docs with artisan apidoc:generate

Routes

➜  lumen-api-starter git:(update-5.8) ✗ ./artisan route:list
+------+--------------------------------+-----------------------+-------------------------------------+-----------------+--------------------------+
| Verb | Path                           | NamedRoute            | Controller                          | Action          | Middleware               |
+------+--------------------------------+-----------------------+-------------------------------------+-----------------+--------------------------+
| GET  | /                              |                       | None                                | Closure         |                          |
| POST | /auth/register                 | auth.register         | App\Http\Controllers\AuthController | register        |                          |
| POST | /auth/login                    | auth.login            | App\Http\Controllers\AuthController | login           |                          |
| GET  | /auth/verify/{token}           | auth.verify           | App\Http\Controllers\AuthController | verify          |                          |
| POST | /auth/password/forgot          | auth.password.forgot  | App\Http\Controllers\AuthController | forgotPassword  |                          |
| POST | /auth/password/recover/{token} | auth.password.recover | App\Http\Controllers\AuthController | recoverPassword |                          |
| GET  | /auth/user                     | auth.user             | App\Http\Controllers\AuthController | getUser         | auth                     |
| GET  | /admin                         |                       | None                                | Closure         | auth, role:administrator |
+------+--------------------------------+-----------------------+-------------------------------------+-----------------+--------------------------+

Artisan Commands

➜  lumen-api-starter git:(master) ./artisan 
Laravel Framework Lumen (5.6.4) (Laravel Components 5.6.*)

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  clear-compiled            Remove the compiled class file
  dump-server               Start the dump server to collect dump information.
  help                      Displays help for a command
  list                      Lists commands
  migrate                   Run the database migrations
  optimize                  Optimize the framework for better performance
  serve                     Serve the application on the PHP development server
  tinker                    Interact with your application
 auth
  auth:clear-resets         Flush expired password reset tokens
  auth:generate-paseto-key  Creates a new authentication key for paseto
 cache
  cache:clear               Flush the application cache
  cache:forget              Remove an item from the cache
  cache:table               Create a migration for the cache database table
 clockwork
  clockwork:clean           Cleans Clockwork request metadata
 db
  db:seed                   Seed the database with records
 ide-helper
  ide-helper:eloquent       Add \Eloquent helper to \Eloquent\Model
  ide-helper:generate       Generate a new IDE Helper file.
  ide-helper:meta           Generate metadata for PhpStorm
  ide-helper:models         Generate autocompletion for models
 key
  key:generate              Set the application key
 make
  make:command              Create a new Artisan command
  make:controller           Create a new controller class
  make:event                Create a new event class
  make:job                  Create a new job class
  make:listener             Create a new event listener class
  make:mail                 Create a new email class
  make:middleware           Create a new middleware class
  make:migration            Create a new migration file
  make:model                Create a new Eloquent model class
  make:policy               Create a new policy class
  make:provider             Create a new service provider class
  make:request              Create a new form request class
  make:resource             Create a new resource
  make:seeder               Create a new seeder class
  make:test                 Create a new test class
 migrate
  migrate:fresh             Drop all tables and re-run all migrations
  migrate:install           Create the migration repository
  migrate:refresh           Reset and re-run all migrations
  migrate:reset             Rollback all database migrations
  migrate:rollback          Rollback the last database migration
  migrate:status            Show the status of each migration
 queue
  queue:failed              List all of the failed queue jobs
  queue:failed-table        Create a migration for the failed queue jobs database table
  queue:flush               Flush all of the failed queue jobs
  queue:forget              Delete a failed queue job
  queue:listen              Listen to a given queue
  queue:restart             Restart queue worker daemons after their current job
  queue:retry               Retry a failed queue job
  queue:table               Create a migration for the queue jobs database table
  queue:work                Start processing jobs on the queue as a daemon
 route
  route:list                Display all registered routes.
 schedule
  schedule:run              Run the scheduled commands

Generated Docs Screenshot

image

lumen-api-starter's People

Contributors

mstaack avatar stefanvanherwijnen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lumen-api-starter's Issues

Multiple users tables

I know that it may not be an issue (and I apologize in advance for this), but i'd like to know if there's a way to have multiple users tables, like "providers", where this provider can login in a different subdomain, the main idea is to decentralize the login, as part of the software business model.

Turn of user email verification

Sorry to bother you here ...
First time using Lumen, only used Laravel before.

The current setup requires the user to verify their email.

In Laravel I can remove the "Illuminate\Contracts\Auth\MustVerifyEmail" contract on the User Model, but I can't find it in this installation. Can you please direct me to where I can disable the email verification?

(Took me a while to figure out why the seeded [email protected] returned the email/password error")

Please update DatabaseSeeder.php

It is easier to log in with the seeded demo user if it is verified.

<?php

use App\User;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call([
            RolesSeeder::class,
        ]);
        $user = User::createFromValues('John Doe', '[email protected]', 'password')->assignRole('administrator');
        $user->verify();
    }
}

verify the `demo` user in database seed

At first I tried to login , and after a few hours, I found that:

You need to verify the user before you can login.
If the email settings are correct you should receive an email. You can also use

$user = App\User::where('email', -yourEmail-)->first();
$user->verify();

Originally posted by @stefanvanherwijnen in #29 (comment)

Access protected routes via Paseto token

Hi there,

I would like to know how I can access the protected routes after loggin in with my email and password. I do receive the token but when I post it to /auth/user I only get 401.

Best regards
linatt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.