From 8a0cac89a08b778d29031d5e214aae2015b5d19b Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Tue, 7 Aug 2018 10:31:08 +0800 Subject: [PATCH] Update readme.md --- readme.md | 64 +++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/readme.md b/readme.md index 4062d08..6aa90ef 100644 --- a/readme.md +++ b/readme.md @@ -1,10 +1,14 @@ # Laravel Simple CRUD Generator [![Build Status](https://travis-ci.org/nafiesl/SimpleCrudGenerator.svg?branch=master)](https://travis-ci.org/nafiesl/SimpleCrudGenerator) +[![Total Downloads](https://poser.pugx.org/luthfi/simple-crud-generator/downloads)](https://packagist.org/packages/luthfi/simple-crud-generator) -An artisan `make:crud` command to create a simple CRUD feature on your Laravel 5.4 and 5.5 application. +An artisan `make:crud` command to create a simple CRUD feature on our Laravel 5.5 application. This package is fairly simple, to **boost test-driven development** method on our laravel application. + +--- ## About this package With this package installed on local environment, we can use (e.g.) `php artisan make:crud Vehicle` command to generate some files : + - `App\Vehicle.php` eloquent model - `xxx_create_vehicles_table.php` migration file - `VehiclesController.php` @@ -17,10 +21,12 @@ With this package installed on local environment, we can use (e.g.) `php artisan - `VehiclePolicyTest.php` unit test class in `tests/Unit/Policies` directory It will update some file : + - Update `routes/web.php` to add `vehicles` resource route - Update `app/providers/AuthServiceProvider.php` to add Vehicle model Policy class in `$policies` property It will also create this file **if it not exists** : + - `resources/lang/app.php` lang file if it not exists - `tests/BrowserKitTest.php` base Feature TestCase class if it not exists @@ -28,9 +34,7 @@ It will also create this file **if it not exists** : The main purpose of this package is for faster **Test-driven Development**, it generates model CRUD scaffolds complete with Testing Classes which will use [Laravel Browserkit Testing](https://github.com/laravel/browser-kit-testing) package and [PHPUnit](https://packagist.org/packages/phpunit/phpunit) version 6. -#### Model Attribute/column - -The Model and table will **only have 2** pre-definded attributes or columns : **name** and **description** on each generated model and database table. You can continue working on other column on the table. +--- ## How to install @@ -59,6 +63,8 @@ Luthfi\CrudGenerator\ServiceProvider::class, 'Html' => Collective\Html\HtmlFacade::class, ``` +--- + ## How to use Just type in terminal `$ php artisan` and we will find the `make:crud` command, it will create simple Laravel CRUD files of given **model name**. @@ -75,10 +81,14 @@ $ php artisan make:crud-api $ php artisan make:crud-simple ``` +#### Model Attribute/column + +The Model and table will **only have 2 pre-definded** attributes or columns : **name** and **description** on each generated model and database table. You can continue working on other column on the table. + For example we want to create CRUD for '**App\Vehicle**' model. ```bash -$ php artisan make:crud Vehicle +$ php artisan make:crud-simple Vehicle Vehicle resource route generated on routes/web.php. Vehicle model generated. @@ -98,7 +108,7 @@ VehiclePolicyTest (model policy) generated. CRUD files generated successfully! ``` -Make sure we have set our database credential on `.env` file. Then : +Make sure we have **set our database credential** on `.env` file. Then : ```bash $ php artisan migrate @@ -115,14 +125,24 @@ If we want to generate API Controller with feature tests, we use following comma $ php artisan make:crud-api Vehicle ``` -By default, we use Laravel Token Based Authentication, so we need to update our user model. +By default, we use Laravel **Token Based Authentication**, so we need to update our user model. -1. Add `api_token` as **fillable** property on **User model**. -2. Add `api_token` **field** on our **UserFactory**. -3. Add `api_token` **column** on our **users_table_migration**. +1. Add `api_token` **column** on our **users_table_migration**. +2. Add `api_token` as **fillable** property on **User model**. +3. Add `api_token` **field** on our **UserFactory**. + +--- ## Config file +You can configure your own by publishing the config file: + +```bash +$ php artisan vendor:publish --provider="Luthfi\CrudGenerator\ServiceProvider" +``` + +That will generate `config/simple-crud.php` file. + By default, this package have some configuration: ```php @@ -140,18 +160,14 @@ return [ ]; ``` -You can configure your own by publishing the config file: - -```bash -$ php artisan vendor:publish --provider="Luthfi\CrudGenerator\ServiceProvider" -``` - -That will generate `config/simple-crud.php` file. +--- ## Attention - The package will creates the **Model** class file, the command will stop if the **Model already exists**. -- You need a `resources/views/layouts/app.blade.php` view file, simply create one with `php artisan make:auth` command. You can change this configuration via the `config/simple-crud.php` file. +- **You need** a `resources/views/layouts/app.blade.php` view file, simply create one with `php artisan make:auth` command. You can change this configuration via the `config/simple-crud.php` file. + +--- ## Screenshots @@ -159,9 +175,9 @@ Visit your application in new resource route : `http://127.0.0.1:8000/vehicles` ![Generated CRUD page by Simple CRUD Generator](screenshots/simple-crud-generator-01.jpg) -### Let's try the generated testing suite +#### Generated testing suite -Next, to use the generated testing classes, we can set the database environment using *in-memory* database SQLite. Open `phpunit.xml`. Add two lines below on the `env` : +Next, let us try the generated testing suite. To use the generated testing classes, we can set the database environment using ***in-memory* database SQLite**. Open `phpunit.xml`. Add two lines below on the `env` : ```xml @@ -184,6 +200,14 @@ All tests should be passed. ![Generated Testing Suite on Simple CRUD Generator](screenshots/simple-crud-generator-02.jpg) +--- + +## Issue/Proposal + +If you find any issue, or want to propose some idea to help this package better, please [create an issue](https://github.com/nafiesl/SimpleCrudGenerator/issues) in this github repo. + +--- + ## License This package is open-sourced software licensed under the [MIT license](LICENSE).