Skip to content

Latest commit

 

History

History
75 lines (64 loc) · 1.66 KB

pcli.md

File metadata and controls

75 lines (64 loc) · 1.66 KB

< Main

PCLI

As you have seen in other sections on how to generate Action/Model/Middleware/Request through PCLI from root. We can also generate classes apart from the above options.

Class

php pcli create class Sample

It will create class at /app/Sample.php with content

<?php
namespace App;

class Sample
{
    
}

To create class file at different location, you can do

php pcli create class Helpers.Sample

The path we are passing is seprated by dot . and it will create class at /App/Helpers/Sample.php with content

<?php
namespace App\Helpers;

class Sample
{
    
}

Trait

Traits can also be generated by command

php pcli create trait Sample

It will create class at app/Traits/Sample.php with content

<?php
namespace App\Traits;

trait Sample
{
    
}

Note: trait files will only be created in app/Traits/ directory with cli run.

Multi Level Directory File

We can also go to multi level paths for generating class/trait/action/model/request/middleware file.

php pcli create action User.Details

It will create file at app/Actions/User/Details.php with content

<?php

namespace App\Actions\User;

use PHPattern\Action;

class Details extends Action
{
    
}

Same applies to other cli action types for generating files and path given must be separated by dot .

php pcli create class App.User.Details
php pcli create trait User.Details
php pcli create action User.Details
php pcli create model User.Details
php pcli create request User.Details
php pcli create middleware User.Details