11# Database Repository / PHP Repository / Laravel Repository
22
33## Installation
4- Use following command to add this package to composer development requirement.
4+ Use the following command to add this package to the composer development requirement.
55``` bash
66composer require nanvaie/database-repository --dev
77```
88
99### Setup Laravel Repository
10- Then run following command in console to publish necessary assets in your project directory.
10+ Then run the following command in the console to publish the necessary assets in your project directory.
1111``` bash
1212php artisan vendor:publish --tag=database-repository-config
1313```
1414
1515### Setup Lumen Repository
16- Navigate to ` app.php ` in ` bootstrap ` folder and add following line after service providers registrations:
16+ Navigate to ` app.php ` in ` bootstrap ` folder and add the following line after service providers registrations:
1717``` php
1818// snip
1919if ($app->environment('local', 'testing')) {
2020 $app->register(Nanvaie\DatabaseRepository\DatabaseRepositoryServiceProvider::class);
2121}
2222// snip
2323```
24- Copy [ repository.php] ( config/repository.php ) to project config folder located at project root.
24+ Copy [ repository.php] ( config/repository.php ) to the project config folder located at the project root.
2525
2626Note: Make sure to run ` composer dump-autoload ` after these changes.
2727
2828## Usage
29+ To use this package easily, you can run the following command. It will create all the required components such as Entity, IRepository, Repository, MySqlRepository, RedisRepository, Resource, and Factory for the users table.
30+ ``` bash
31+ php artisan repository:make-all --table_names=users --strategy_name=QueryCacheStrategy
32+ ```
2933List of artisan commands:
3034
3135| Command | Inputs | Options | Description |
@@ -44,24 +48,24 @@ List of artisan commands:
4448### Options Explanation
4549- ` -f|--force ` : Force commands to override existing files.
4650- ` -d|--delete ` : Delete already created files.
47- - ` -k|--foreign-keys ` : Try to detect foreign keys of table.
48- - ` -g|--add-to-git ` : Add created files to git repository.
51+ - ` -k|--foreign-keys ` : Try to detect foreign keys of a table.
52+ - ` -g|--add-to-git ` : Add created files to the git repository.
4953- ` -a|--all-tables ` : Use all existing tables.
5054- ` --table_names= ` : Add table names, separate names with comma.
5155- ` --selected_db= ` : Use between ` Mysql ` ,` Redis ` , If it does not send, the value will return from ` config/repository.php `
52- - ` --strategy_name= ` : add a trait to your redis repository based on the strategy you choose
56+ - ` --strategy_name= ` : add a trait to your Redis repository based on the strategy you choose
5357
54- Example 1. Create new Entity for a table named 'users'.
58+ Example 1. Create a new Entity for a table named 'users'.
5559``` bash
5660php artisan repository:make-entity users
5761```
5862
59- Example 2. Create all necessary classes for two tables named 'users' and 'customers' with enabled foreign key option.
63+ Example 2. Create all necessary classes for two tables named 'users' and 'customers' with an enabled foreign key option.
6064``` bash
6165php artisan repository:make-all --table_names=users,customers -k
6266```
6367
64- Example 3. Create all necessary classes for all tables with enabled foreign key option(this may be used for new projects).
68+ Example 3. Create all necessary classes for all tables with an enabled foreign key option(this may be used for new projects).
6569``` bash
6670php artisan repository:make-all -a -k
6771```
0 commit comments