-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve rockshell api and add docs
- Loading branch information
1 parent
b0137bb
commit 6194f19
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# RockShell Integration | ||
|
||
You can load RockShell or any registered RockShell command directly from RockMigrations. | ||
|
||
## Use Case | ||
|
||
Imagine you are developing a command for RockShell. While developing you want to quickly iterate and see if what you are coding is actually working, right? You could code, then fire the command in the console, then code, then fire the command again... | ||
|
||
That's not fun and you lose all the great dumping and debugging that you get from TracyDebugger. | ||
|
||
As of now there is a better way! | ||
|
||
## Loading Commands in site/ready.php | ||
|
||
Let's say we had this command in `/site/modules/Site/RockShell/Commands/SiteDoSomething.php`: | ||
|
||
```php | ||
<?php | ||
|
||
namespace Site; | ||
|
||
use RockShell\Command; | ||
|
||
class SiteDoSomething extends Command | ||
{ | ||
public function handle() | ||
{ | ||
$this->doSomething(); | ||
return self::SUCCESS; | ||
} | ||
|
||
public function doSomething(): void | ||
{ | ||
// do something | ||
|
||
// log when not in CLI | ||
if(!$this->isCLI()) bd("I'm doing something!"); | ||
} | ||
} | ||
``` | ||
|
||
While developing you could add this to `ready.php` and when using LiveReload you'll get results whenever you save your file without ever leaving your IDE! | ||
|
||
```php | ||
rockmigrations() | ||
->rockshell() | ||
->get("site:do:something") | ||
->doSomething(); | ||
``` | ||
|
||
Once you are done and everything works as expected you can simply execute your command from the command line! |