定制 sqits/laravel-api-skeleton 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sqits/laravel-api-skeleton

Composer 安装命令:

composer require sqits/laravel-api-skeleton

包简介

Package to create a complete Laravel API resource according to stub files.

README 文档

README

Latest Version on Packagist StyleCI Total Downloads

This Laravel package creates an artisan command to generate an api skeleton.

php artisan make:apiskeleton

Artisan will ask 2 questions to define in which namespace and which name your skeleton should use

What is the namespace for the skeleton? [ApiSkeleton]
> Foo/Bar

What is the name for the skeleton? [ApiSkeleton}
> Hat

After the command the following files are created (may be different according to your config)

app 
└───Http
    └───Controllers
    │   └───Foo
    │       └───Bar
    │           |   HatController.php
    └───Requests
    │   └───Foo
    │       └───Bar
    │           |   StoreHatRequest.php
    │           |   UpdateHatRequest.php
    └───Resources
    │   └───Foo
    │       └───Bar
    │           |   Hat.php
    │           |   HatCollection.php
    Hat.php

database
└───factories
│   └───Foo
│       └───Bar
│           |   HatFactory.php
└───migrations
│   |   xxxx_xx_xx_xxxxxx_create_hats_table.php
└───seeds
    └───Foo
        └───Bar
            |   HatTestSeeder.php
 
tests
└───Feature
    └───Foo
        └───Bar
            |   HatDestroyTest.php 
            |   HatIndexTest.php 
            |   HatShowTest.php 
            |   HatStoreTest.php 
            |   HatUpdateTest.php    

Installation and usage

This package requires PHP 7.1 and Laravel 5.6 or higher. Install the package by running the following command in your console;

composer require sqits/laravel-api-skeleton

You can publish the config file with:

php artisan vendor:publish --provider="Sqits\ApiSkeleton\ApiSkeletonServiceProvider" --tag="config"

This is the contents of the published config file:

return [

    'files' => [

        /*
         * Define if the model should be created when a new API skeleton is created.
         */

        'models' => true,

        /*
         * Define if the migration for the model should be created when a new API skeleton is created.
         * The models should be set to true for the migrations to be created.
         */

        'migrations' => true,

        /*
         * Define if the controller should be created when a new API skeleton is created.
         * When the model is created also, the model would be used automatically in the controller.
         */

        'controllers' => true,

        /*
         * Define if the requests should be created when a new API skeleton is created.
         * The following requests will be made StoreModelRequest and UpdateModelRequest
         */

        'requests' => true,

        /*
         * Define if the resources should be created when a new API skeleton is created.
         * The following resources will be made Model and ModelCollection.
         */

        'resources' => true,

        /*
         * Define if the tests should be created when a new API skeleton is created.
         * The following tests will be made ModelIndexText, ModelShowTest, ModelStoreTest,
         * ModelUpdateTest and ModelDestroyTest.
         *
         * Value should be true for creating the tests inside the Feature folder. set
         * the value to 'unit' to create the tests inside the Unit folder.
         */

        'tests' => true,

        /*
         * Define if the seeders should be created when a new API skeleton is created.
         */

        'seeders' => [

            /*
             * Define if the default seeder for the model should be created when a new
             * API skeleton is created.
             */

            'defaults' => false,

            /*
             * Define if the test seeder for the model should be created when a new
             * API skeleton is created.
             */

            'tests' => true,

        ],

        /*
         * Define if the factories should be created when a new API skeleton is created.
         * The following resources will be made Model and ModelCollection.
         */

        'factories' => true,
        
        /*
         * Define if the services should be created when a new API skeleton is created.
         * You should define a folder in the config where the service should be located.
         *
         * If this option is set to true, artisan will ask the user to confirm the generation
         * of the service to make it optional per skeleton. If you want to skip the question
         * your should add --service to the make:apiskeleton command.
         */

        'services' => false,
        
        /*
         * Define if the repositories should be created when a new API skeleton is created.
         * You should define a folder in the config where the repository should be located.
         * 
         * If this option is set to true, artisan will ask the user to confirm the generation
         * of the factory to make it optional per skeleton. If you want to skip the question
         * your should add --repository to the make:apiskeleton command.
         */

        'repositories' => false,

    ],

    'folders' => [

        /*
         * When creating the models, the models will be placed directly in the app folder
         * without a specific namespace. If you are using your own folder, please provide
         * the name of the folder. The model will be placed inside this folder with the
         * given namespace.
         */

        'models' => null,
        
        /*
         * When creating the services, the services will be placed inside the given
         * folder which will be placed inside the app folder of your application.
         */

        'services' => 'Services',
        
        /*
         * When creating the repositories, the repositories will be placed inside the given
         * folder which will be placed inside the app folder of your application.
         */
        
        'repositories' => 'Repositories',

    ],


    /*
     * By default the resource collection will append `Collection` to the name. If you would
     * like to have the name of the collection pluralized set this option to true.
     */

    'use_pluralized_collections' => false,
];

You can publish the stub files with:

php artisan vendor:publish --provider="Sqits\ApiSkeleton\ApiSkeletonServiceProvider" --tag="stubs"

The stub files are placed inside your resources folder and will contain:

resources 
└───stubs
    └───apiskeleton
        |   service.stub
        |   repository.stub

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security-related issues, please email to info@sqits.nl instead of using the issue tracker.

Credits

License

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

统计信息

  • 总下载量: 106
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固