Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ jobs:
run: composer dump-autoload

- name: Lint PHP files
run: find src application tests -name '*.php' -print0 | xargs -0 -n1 php -l
run: |
php -l shift
find src application tests -name '*.php' -print0 | xargs -0 -n1 php -l

- name: Run API core tests
run: composer test

- name: Verify route list command
run: php shift.php route:list
run: ./shift route:list

version-label:
name: Version label required
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,31 +350,31 @@ http://127.0.0.1:8000/health
List registered API routes:

```sh
php shift.php route:list
./shift route:list
```

Run the example module command:

```sh
php shift.php health
./shift health
```

Generate module scaffolding:

```sh
php shift.php create:module Billing
./shift create:module Billing
```

Generate module-owned classes:

```sh
php shift.php create:controller --module=Billing InvoiceController
php shift.php create:controller Billing:InvoiceController
php shift.php create:model Billing:Invoice
php shift.php create:service Billing:Invoice
php shift.php create:command Billing:SyncInvoices
php shift.php create:middleware Billing:Audit
php shift.php create:dto Billing:CreateInvoice
./shift create:controller --module=Billing InvoiceController
./shift create:controller Billing:InvoiceController
./shift create:model Billing:Invoice
./shift create:service Billing:Invoice
./shift create:command Billing:SyncInvoices
./shift create:middleware Billing:Audit
./shift create:dto Billing:CreateInvoice
```

Generator commands normalize module and class names to PHP class conventions. Missing suffixes are added for controllers, services, middleware, and DTOs.
Expand Down
2 changes: 1 addition & 1 deletion application/modules/Health/Commands/Health.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php health';
return 'Usage: ./shift health';
}

public function getDescription(): string
Expand Down
22 changes: 11 additions & 11 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -471,21 +471,21 @@ <h3>Models</h3>

<section id="cli">
<h2>CLI</h2>
<p>The CLI entry point is <code>shift.php</code>. Built-in commands live under <code>Console\Commands</code>, and module commands are loaded from module command mappings.</p>
<p>The CLI entry point is <code>shift</code>. Built-in commands live under <code>Console\Commands</code>, and module commands are loaded from module command mappings.</p>

<pre><code>php shift.php route:list
php shift.php health</code></pre>
<pre><code>./shift route:list
./shift health</code></pre>

<p>Create commands scaffold modules and module-owned classes:</p>

<pre><code>php shift.php create:module Billing
php shift.php create:controller --module=Billing InvoiceController
php shift.php create:controller Billing:InvoiceController
php shift.php create:model Billing:Invoice
php shift.php create:service Billing:Invoice
php shift.php create:command Billing:SyncInvoices
php shift.php create:middleware Billing:Audit
php shift.php create:dto Billing:CreateInvoice</code></pre>
<pre><code>./shift create:module Billing
./shift create:controller --module=Billing InvoiceController
./shift create:controller Billing:InvoiceController
./shift create:model Billing:Invoice
./shift create:service Billing:Invoice
./shift create:command Billing:SyncInvoices
./shift create:middleware Billing:Audit
./shift create:dto Billing:CreateInvoice</code></pre>

<p>Controller, service, middleware, and DTO generators add the expected class suffix when it is missing. Commands accept either <code>--module=Billing Name</code> or <code>Billing:Name</code>.</p>
<p>Generator templates live in <code>src/Console/Generator/stubs</code>.</p>
Expand Down
4 changes: 2 additions & 2 deletions shift.php → shift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/php
#!/usr/bin/env php
<?php

use Shift\App;
use Shift\Console\Shift;

require_once 'bootstrap.php';
require_once __DIR__ . '/bootstrap.php';
App::setHelpers();
$console = new Shift($argv);
$console->run();
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:command --module={name} {CommandName}';
return 'Usage: ./shift create:command --module={name} {CommandName}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:controller --module={name} {ControllerName}';
return 'Usage: ./shift create:controller --module={name} {ControllerName}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:dto --module={name} {DtoName}';
return 'Usage: ./shift create:dto --module={name} {DtoName}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:middleware --module={name} {MiddlewareName}';
return 'Usage: ./shift create:middleware --module={name} {MiddlewareName}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:model --module={name} {ModelName}';
return 'Usage: ./shift create:model --module={name} {ModelName}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:module {name}';
return 'Usage: ./shift create:module {name}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CreateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php create:service --module={name} {ServiceName}';
return 'Usage: ./shift create:service --module={name} {ServiceName}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/RouteList.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function execute(mixed ...$args): void

public function getHelp(): string
{
return 'Usage: php shift.php route:list';
return 'Usage: ./shift route:list';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Generator/stubs/command.stub
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class {{ class }} implements CommandInterface

public function getHelp(): string
{
return 'Usage: php shift.php {{ command }}';
return 'Usage: ./shift {{ command }}';
}

public function getDescription(): string
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ConsoleCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
$command = file_get_contents($modulesPath . '/Billing/Commands/SyncInvoices.php');
assertStringContains('class Invoice extends Model', $model, 'Generated models should extend the base model.');
assertStringContains("protected string \$table = 'invoices';", $model, 'Generated models should define a table name.');
assertStringContains('return \'Usage: php shift.php sync:invoices\';', $command, 'Generated command help should use CLI command syntax.');
assertStringContains('return \'Usage: ./shift sync:invoices\';', $command, 'Generated command help should use CLI command syntax.');
} finally {
removeDirectory(dirname($modulesPath));
}
Expand Down
Loading