Class Generator¶
The Class Generator creates a simple PHP class with customizable namespace, parent class, interfaces, and description.
Command¶
Arguments¶
| Argument | Description |
|---|---|
name |
The name of the class to create (e.g., User) |
Options¶
| Option | Description | Default |
|---|---|---|
--namespace |
The namespace of the class | Empty (uses the configured namespace prefix) |
--extends |
The parent class to extend from | None |
--implements |
The interfaces to implement (can be used multiple times) | None |
--description |
The class description for PHPDoc | None |
Examples¶
Basic Usage¶
This will generate a simple class:
With Custom Namespace¶
This will generate:
With Parent Class¶
This will generate:
With Interfaces¶
php bin/console make:elegant:class Repository --implements="App\Domain\Repository\RepositoryInterface" --implements="Countable"
This will generate:
<?php
namespace App;
use App\Domain\Repository\RepositoryInterface;
use Countable;
/**
* Repository class.
*/
class Repository implements RepositoryInterface, Countable
{
}
With Description¶
This will generate:
Generated File Location¶
The generated file will be placed in the directory corresponding to the namespace, relative to the configured directory prefix.
For example, if the namespace is App\Domain\Model and the directory prefix is src, the file will be created at src/Domain/Model/User.php.