webpress / core
此包的最新版本(3.1.87)没有可用的许可信息。
Webpress 核心模块
此包的官方仓库似乎已不存在,因此该包已被冻结。
3.1.87
2021-11-17 01:58 UTC
Requires
- cviebrock/eloquent-sluggable: 7.0.1
- dingo/blueprint: 0.4.2
- illuminate/auth: ^7.0
- illuminate/contracts: ^7.0
- illuminate/http: ^7.0
- illuminate/routing: ^7.0|^8.0
- illuminate/support: ^7.0|^8.0
- lcobucci/jwt: 3.3.3
- league/flysystem-aws-s3-v3: 1.0.25
- league/flysystem-cached-adapter: 1.0.9
- league/fractal: 0.19.2
- namshi/jose: 7.2.3
- nesbot/carbon: ^1.0 || ^2.0
Requires (Dev)
- orchestra/testbench: 5.0.0
- phpunit/phpunit: 8.5.13
- spatie/phpunit-watcher: 1.23.0
- dev-master
- 3.1.87
- 3.1.86
- 3.1.85
- 3.1.83
- 3.1.82
- 3.1.81
- 3.1.80
- 3.1.79
- 3.1.78
- 3.1.77
- 3.1.76
- 3.1.74
- 3.1.73
- 3.1.72
- 3.1.71
- 3.1.70
- 3.1.69
- 3.1.68
- 3.1.67
- 3.1.66
- 3.1.65
- 3.1.64
- 3.1.63
- 3.1.61
- 3.1.60
- 3.1.59
- 3.1.58
- 3.1.57
- 3.1.56
- 3.1.54
- 3.1.53
- 3.1.52
- 3.1.51
- 3.1.50
- 3.1.49
- 3.1.48
- 3.1.47
- 3.1.46
- 3.1.45
- 3.1.44
- 3.1.43
- 3.1.42
- 3.1.41
- 3.1.40
- 3.1.39
- 3.1.38
- 3.1.37
- 3.1.36
- 3.1.35
- 3.1.34
- 3.1.33
- 3.1.32
- 3.1.31
- 3.1.30
- 3.1.29
- 3.1.28
- 3.1.27
- 3.1.26
- 3.1.25
- 3.1.24
- 3.1.23
- 3.1.22
- 3.1.20
- 3.1.19
- 3.1.18
- 3.1.17
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.34
- 3.0.33
- 3.0.32
- 3.0.31
- 3.0.30
- 3.0.29
- 3.0.28
- 3.0.27
- 3.0.26
- 3.0.25
- 3.0.24
- 3.0.23
- 3.0.22
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0.17
- 3.0.16
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.12
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.6
- 3.0.5
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.1
- 0.19.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.1
- dev-dev/v9.0
- dev-chore/host-own-dependency
This package is auto-updated.
Last update: 2022-06-17 10:32:14 UTC
README
此包包含其他 3 个包,分别是 dingo/api
、tymon/jwt-auth
、prettus/l5-repository
,它们提供了强大的代码库来构建 APIs。
安装
Composer
要将此包包含到您的项目中,请运行以下命令。
composer require vicoders/core
配置和迁移
运行以下命令以发布配置和迁移文件。
php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider"
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
php artisan vendor:publish --provider "Prettus\Repository\Providers\RepositoryServiceProvider"
环境
在 .env 文件中,我们需要一些配置。
API_PREFIX=api
API_VERSION=v1
API_NAME="Your API Name"
API_DEBUG=false
在 .env 文件中生成 JWT_SECRET。
php artisan jwt:secret
APIs
Vicoders/Core
包提供了一个基础的 VCComponent\Laravel\Vicoders\Core\Controllers\ApiController
和上传文件的 API 在 VCComponent\Laravel\Vicoders\Core\Controllers\FileController
{url}/api/file/upload
上传文件 API 使用
POST
HTTP 方法。
修改 config/filesystems.php
以使用 API
'disks' => [ 'local' => [ 'driver' => 'local', 'root' => public_path(), ],
要使用此 API,请在请求中添加以下参数
头部
请求
文件验证器
您可以使用自己的 FileValidator
。只需在您的验证器中实现 FileValidatorInterface
并在 AppServiceProvider
中绑定它。
<?php namespace App\Providers; use App\Validators\FileValidator; use Illuminate\Support\ServiceProvider; use VCComponent\Laravel\Vicoders\Core\Contracts\FileValidatorInterface; class AppServiceProvider extends ServiceProvider { /** * Register any application services. * * @return void */ public function register() { $this->app->bind(FileValidatorInterface::class, FileValidator::class); } }
<?php namespace App\Validators; use VCComponent\Laravel\Vicoders\Core\Contracts\FileValidatorInterface; use VCComponent\Laravel\Vicoders\Core\Validators\AbstractValidator; class FileValidator extends AbstractValidator implements FileValidatorInterface { protected $rules = [ 'RULE_CREATE' => [ 'file' => ['required', 'mimes:csv'], 'upload_path' => ['required', 'regex:/[a-z]*/'], ], ]; }
异常
Vicoders/Core
包提供了一些常用的 Exception
类
VCComponent\Laravel\Vicoders\Core\Exceptions\NotFoundException::class, VCComponent\Laravel\Vicoders\Core\Exceptions\PermissionDeniedException::class,
您可以在您的 Controller
中使用这些 Exception
类
use VCComponent\Laravel\Vicoders\Core\Exceptions\NotFoundException; use VCComponent\Laravel\Vicoders\Core\Controllers\ApiController; class UserController extends ApiController { public function show(Request $request, $id) { $user = $this->entity->find($id); if (!$user) { throw new NotFoundException('User'); } } }
验证器
Vicoders/Core
包提供了一些 AbstractValidator
,您可以使用它来创建您的 Validator
类
use VCComponent\Laravel\Vicoders\Core\Validators\AbstractValidator; class PostValidator extends AbstractValidator