|
1 |
| -# How to contribute to laravel-makeclass |
| 1 | +#Laravel Make Class |
| 2 | +### Features |
2 | 3 |
|
3 |
| -Hey, thank you for contributing. Here are some tips to make it easy for you. |
| 4 | +- Create a php class from the command for any directory in the root name-space; |
| 5 | +- Store a custom path as an alias and use alias instead of full path. |
| 6 | +- Create interface | class | enum | trait. |
| 7 | +- Create final and abstract classes |
| 8 | +- Create class with a declare strict_type |
4 | 9 |
|
5 |
| -## Committing code |
6 |
| - |
7 |
| -1. Fork the project |
8 |
| -1. `git clone` it and `composer install` the dependencies |
9 |
| -1. Create a new branch |
10 |
| -1. Think about how the changes you are about to make can be tested, optionally write tests before coding |
11 |
| -1. Run tests, make sure they fail |
12 |
| -1. Write the actual code to make the tests pass |
13 |
| -1. Open a pull request detailing your changes. Make sure to follow the [template](.github/PULL_REQUEST_TEMPLATE.md) |
| 10 | +### Installation |
| 11 | +```bash |
| 12 | +composer require opheus2/laravel-makeclass |
| 13 | +``` |
14 | 14 |
|
15 |
| -## Testing |
| 15 | +###Usages |
| 16 | +> File is created in root name-space. E.b App |
| 17 | +```bash |
| 18 | +php artisan make:class {name} |
| 19 | +``` |
| 20 | +Default type is class. |
16 | 21 |
|
17 |
| -I use **PHPUnit** for testing. |
| 22 | +------------ |
18 | 23 |
|
19 |
| -Have a new feature? You can start off by writing some tests that detail |
20 |
| -the behaviour you want to achieve and go from there. |
| 24 | +> File is created in test folder in root name-space. E.b App/Test |
| 25 | +```bash |
| 26 | +php artisan make:class Test\{name} |
| 27 | +``` |
| 28 | +------------ |
| 29 | +> Create an interface type of class |
| 30 | +```bash |
| 31 | +php artisan make:class {name} -i |
| 32 | + or |
| 33 | +php artisan make:class {name} --type interface |
| 34 | +``` |
| 35 | +------------ |
21 | 36 |
|
22 |
| -Fixing a bug? The best way to ensure it is fixed for good and never comes |
23 |
| -back is to write a failing test for it and then make it pass. If you can |
24 |
| -not figure out how to fix it yourself, feel free to submit a PR with a |
25 |
| -failing test. |
| 37 | +| Available types | flags| |
| 38 | +| ------------ | |
| 39 | +| class | (default no flag) | |
| 40 | +| interface | (-i or --interface) | |
| 41 | +| trait | (-T or --trait) | |
| 42 | +| enum | (-e or --enum) | |
26 | 43 |
|
27 |
| -Run the testsuite |
| 44 | +------------ |
| 45 | +> Using custom path with alias |
| 46 | +```bash |
| 47 | +php artisan make:class {name} -i -p="Domains/Services/" --alias="ape" |
| 48 | + or |
| 49 | +php artisan make:class {name} -i -p=Domain\Services\ --alias=ape |
| 50 | + or |
| 51 | +php artisan make:class {name} -i -p Domain\Services\ --alias ape |
| 52 | +``` |
| 53 | +**Please note:** You always need to add a trailing slash at the end for it to work properly. |
| 54 | +I would surely fix that soon. |
28 | 55 |
|
| 56 | +Then you can use alias as path |
29 | 57 | ```bash
|
30 |
| -composer test |
| 58 | +php artisan make:class {name} -i -p="ape" |
31 | 59 | ```
|
| 60 | +This would use the same old/saved path for subsquent file names |
32 | 61 |
|
33 |
| -## Codestyle |
| 62 | +------------ |
| 63 | +> Using modifiers |
| 64 | +```bash |
| 65 | +php artisan make:class {name} -fx |
| 66 | +``` |
| 67 | +This would creat a final class with declare strict_types at the top |
| 68 | +You can use the -x flag to always add the strict type to any class type |
34 | 69 |
|
35 |
| -Formatting is automated through [php_codesniffer](https://github.com/squizlabs/PHP_CodeSniffer). |
| 70 | +------------ |
36 | 71 |
|
37 |
| -Check the codestyle |
| 72 | +| Available modfiers | flags| |
| 73 | +| ------------ | |
| 74 | +| strict | (-x or --strict) | |
| 75 | +| final | (-f or --final) | |
| 76 | +| abstract | (-a or --abstract) | |
38 | 77 |
|
| 78 | +For more info you can do |
39 | 79 | ```bash
|
40 |
| -composer check-style |
| 80 | +php artisan make:class --help |
41 | 81 | ```
|
42 | 82 |
|
43 |
| -Apply automated fixes |
| 83 | +####Thank you |
44 | 84 |
|
45 |
| -```bash |
46 |
| -composer fix-style |
47 |
| -``` |
| 85 | +###TODO |
| 86 | +- [ ] Add check for trailing slash and auto fix |
0 commit comments