Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit 66171ca

Browse files
committed
Improve README
1 parent b83ef2d commit 66171ca

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

README.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# Shift CLI
22
A tool by [Shift](https://laravelshift.com/) to run automated tasks for maintaining your Laravel projects. With this tool, you may also create your own automated tasks and easily share them.
33

4-
This tool is current an _alpha release_. Eventually it will replace the [Shift Workbench](https://laravelshift.com/workbench). All of its free tasks are currently available. Premium tasks will be added in the coming weeks.
4+
The Shift CLI replaces the [Shift Workbench](https://laravelshift.com/workbench) desktop app -- allowing you to run the same tasks conveniently in your local PHP environment. No Electron. No Docker. Similar to the Workbench, the free tasks are available to run immediately. Premium tasks are available with [a license](https://laravelshift.com/cli#licenses).
5+
56

67
## Installation
7-
The Shift CLI is bundled as a PHAR, so it has no dependencies and can be installed without conflicts. To use the Shift CLI for your Laravel project, you may run:
8+
The Shift CLI is bundled as a PHAR, so it has no dependencies and can be installed without conflicts. To use the Shift CLI in your Laravel project, you may install it locally by running:
89

910
```sh
1011
composer require --dev laravel-shift/cli
1112
```
1213

13-
To easily use for all your Laravel projects, you may install the Shift CLI globally by running:
14+
To easily use the Shift CLI for all your Laravel projects, you may install it globally by running:
1415

1516
```sh
1617
composer global require laravel-shift/cli
1718
```
1819

20+
1921
## Basic Usage
2022
The recommended way to use the Shift CLI is to simply run the `shift-cli` command from the root of your Laravel project. This will run the default set of [automated tasks](#automated-tasks). The default tasks are based on conventions found in the latest version of Laravel and its documented examples.
2123

@@ -25,18 +27,19 @@ To run an individual task, or multiple tasks, you may pass them by name to the `
2527
shift-cli run anonymous-migrations facade-aliases
2628
```
2729

28-
By default, the automation is run against all PHP files within your Laravel project. To limit the automation to a path or file, you may set the `--path` option. For example, to run the `anonymous-migrations` task against only the `database/migrations` directory, you may run:
30+
By default, the automation is run against all PHP files under your current path. To limit the automation to a path or file, you may set the `--path` option. For example, to run the `anonymous-migrations` task against only the `database/migrations` directory, you may run:
2931

3032
```sh
3133
shift-cli run --path=database/migrations anonymous-migrations
3234
```
3335

34-
You may also use the `--dirty` option to only run the automation against files which have changed since your last commit. For example, to run the `anonymous-migrations` task against only the modified files, you may run:
36+
You may also use the `--dirty` option to only run the automation against files which have changed since your last commit. For example, to run the `anonymous-migrations` task against only the uncommitted PHP files, you may run:
3537

3638
```sh
3739
shift-cli run --dirty anonymous-migrations
3840
```
3941

42+
4043
## Automated Tasks
4144
- **anonymous-migrations**: (default) Convert class based database migrations into anonymous classes.
4245
- **check-lint**: Check PHP files for syntax errors.
@@ -54,6 +57,46 @@ shift-cli run --dirty anonymous-migrations
5457
- **remove-docblocks**: Remove PHP DocBlocks from code.
5558
- **rules-arrays**: (default) Ensure form request rules are defined as arrays, instead of strings.
5659

60+
61+
## Advanced Usage
62+
The Shift CLI is meant to be integrated into your development workflow. Its focus is refactoring your code and ensuring consistency across your projects. As such, it pairs well with a code formatter. Shift recommends using [Laravel Pint](https://laravel.com/docs/pint) as it is a first-party package which applies the Laravel code style by default. It also uses [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) underneath, so you may easily configure it with all the same options. You may, of course, use PHP CS Fixer directly, or another code formatter like [PHP CS Fixer](https://github.com/squizlabs/PHP_CodeSniffer).
63+
64+
For example, to run the Shift CLI and Pint together, you may run:
65+
66+
```sh
67+
shift-cli && pint
68+
```
69+
70+
Taking this farther, you may automate this by setting up your own Composer script. For example, to run the Shift CLI and Pint together, you may add the following to your `composer.json` file:
71+
72+
```json
73+
{
74+
"scripts": {
75+
"lint": [
76+
"shift-cli",
77+
"pint"
78+
]
79+
}
80+
}
81+
```
82+
83+
Then run: `composer lint`
84+
85+
You may optimize this script by passing the `--dirty` option to both the Shift CLI and Pint. Additionally, you may add the `shift-cli` command to a pre-commit hook to ensure the automation is always run before making a commit.
86+
87+
Finally, you are encouraged to add the `shift-cli` to your CI workflows as well. For example, running the automation on every Pull Request to ensure all merged code consistently follows Laravel conventions.
88+
89+
Examples of setting up Composer scripts and pre-commit hooks may be found in the [Shift CreatorSeries on Laracasts](https://laracasts.com/series/automated-laravel-upgrades/episodes/4).
90+
91+
92+
## Additional Commands
93+
The Shift CLI comes with two additional commands: `publish` and `discover`.
94+
95+
The `publish` command generates a Shift CLI config file - `shift-cli.json`. The generated configuration file includes all of the defaults. You may customize the configuration file to specify which tasks to run by default, additional paths to ignore, and options for individual tasks.
96+
97+
The `discover` command regenerates the Shift CLI task registry. This is done automatically anytime the Shift CLI is updated. However, you may need to run this command if you have included other packages which provide Shift CLI tasks.
98+
99+
57100
## Support Policy
58101
The automated tasks within the Shift CLI prioritize the latest stable version of Laravel (currently Laravel 10). While there will be a grace period when new versions of Laravel are released, you are encouraged to keep your application upgraded (try using [Shift](https://laravelshift.com)).
59102

0 commit comments

Comments
 (0)