Download the PHP package yansongda/laravel-api without Composer

On this page you can find all versions of the php package yansongda/laravel-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-api

Laravel-API

Scrutinizer Code Quality Build Status Latest Stable Version Latest Unstable Version License

当看到 Laravel-API 时,您可能在想:「不是有官方的 Passport 吗,干嘛又重复造轮子?」是的,对于中大型,且需要有 OAuth 授权的应用来说, Passport 的确是一个很好的选择。

但是,对于我们经常开发的中小型应用呢?我们大部分时候可能只是需要提供一个对外服务的 API 接口而已,像是类似于微信开发、支付宝开发那样,给一组 APPID/appsecret 就开始提供纯粹的 API 服务,所以像 Passport 这样的重量级选手,可能就不是更好的选择了。

您可能又会说:「我可以使用 Passport 的 密码授权令牌 啊!」是的,您可以使用,但是,看到 client_id/client_secret/username/password 您作何感想?

您可能又又会说:「我可以使用 Passport 的 客户端凭据授权令牌啊!」是的,您也可以使用,但是:

这些您能忍?

反正我是不能忍,所以,弄了这个轮子。

运行环境

特点

安装

添加 ServiceProvider(optional. if laravel < 5.5)

使用方法

  1. 更改认证驱动

    在 config/auth.php 中,更改 guards.api.driverapi

  2. 在 UserModel 中添加 trait

    config(auth.provider.xx.model) 的类中,添加 use Yansongda\LaravelApi\Models\Traits\HasApiApps

  3. 运行数据迁移

    php artian migrate

  4. 开始使用吧

添加 App 与 accessToken

客户端使用

获取 access_token

使用

有两种方式可以使用

服务端认证

只需要在增加 'auth:api' 的 middleware 即可,增加后,$request->user()/$request->user 即为认证用户,$request->app 即为认证的 app_id

其它

access_token 有效时间

access_token 有效时间默认为 7200 秒,当然,您可以自由设置该值:

授权 token 路由

默认情况下,token 的授权通过自带的 'api/token' 路由进行 post 授权的,如果您想重写 token 的授权方式,您需要首先:

授权 token 路由前缀

默认情况下,自带的路由前缀为 api,如果您想更换为其它,请:

授权 token 路由说明

关于 refresh_token

本着简单易用的原则,并不提供 refresh_token 这种操作,因为发现即使像微信那样提供了 refresh_token 的接口,但是,很多人依然没有去使用,而是直接重新生成新的 access_token。因此,SDK 直接去掉了 refresh_token 的设计。

异常

以上异常如果不想使用默认的信息,均可自行捕获更改相关信息

License

MIT


All versions of laravel-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
illuminate/support Version ^5.1
illuminate/database Version ^5.1
illuminate/http Version ^5.1
illuminate/auth Version ^5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yansongda/laravel-api contains the following files

Loading the files please wait ....