2017 © Pedro Peláez
 

package laravel-php-generator

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

image

davidngugi/laravel-php-generator

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  • Thursday, February 15, 2018
  • by DevDavid
  • Repository
  • 1 Watchers
  • 7 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Laravel PHP Generator

A simple command line tool to generate your Laravel classes, interfaces and traits. Aiming for your higher productivity, (*1)

, (*2)

Installation

composer require davidngugi/laravel-php-generator

Documentation

The package allows you to generate Classes, Interfaces and Traits. You can generate classes that extend another class and implements an interface. The package generates the necessary directories as specified by the -p or path option. Otherwise there is a default path used., (*3)

All paths lead to the App directory. So don't have App in you path., (*4)

The following subsections explain further how to use the various commands, (*5)

NOTE: Replace the string in curly braces with your own values, (*6)

Create a class

php artisan generate:class {class_name_here}

Example

php artisan generate:class Account

this generates the following, (*7)

<?php

namespace App\Logic;

class Account 
{
    //
}

Including the path. E.g Logic/Core, (*8)

php artisan generate:class -p {path_here} {class_name_here}

You can generate multiple classes at a go, (*9)

php artisan generate:class {class1_name_here} {class2_name_here} {class3_name_here}

Create and Extend a class

We use the -e or --extend option. Specify the name of the class to extend. The class to extend will also be generated if it doesn't exist. You can only extend one class, (*10)

php artisan generate:class -e {name_of_class_to_extend} {class_name_here}

Example

php artisan generate:class -e BankAccount CurrentAccount

this generates the following 2 files:, (*11)

<?php

namespace App\Logic;

class BankAccount
{
    //
}

```php <?php, (*12)

namespace App\Logic;, (*13)

use App\Logic\BankAccount;, (*14)

class CurrentAccount extends BankAccount { // }, (*15)


## Generate a class and Implement an Interface We use the -i or --interface option. Specify the name of the interface to implement. NOTE: *The interface name should be without the word 'Interface' at the end, this will be auto-generated* . You can only implement one interface ```bash php artisan generate:class -i{name_of_interface_to_extend} {class_name_here}

Example:

php artisan generate:class -i Finance BankAccount

this will generate the following 2 files:, (*16)

An interface, (*17)

<?php

namespace App\Logic;

interface FinanceInterface
{
    //
}

and a class, (*18)

<?php

namespace App\Logic;

use App\Logic\FinanceInterface;

class BankAccount implements FinanceInterface
{
    //
}

Create and Extend a class and Implement an Interface

We use the above options (-e and -i)., (*19)

php artisan generate:class -e {name_of_class_to_extend} -i  {class_name_here}

Example

php artisan generate:class -e BanckAccount -i Finance CurrentAccount

this generates, (*20)

<?php

namespace App\Logic;

use App\Logic\FinanceInterface;
use App\Logic\BankAccount;

class CurrentAccount extends BankAccount implements FinanceInterface
{
    //
}

NOTE: No existing files or folders will be overwritten by these commands, (*21)

Create an Interface

We use the generate:interface artisan command. This also supports the -p or --path option to specify the directory path., (*22)

App\Logic\Interfaces is the default path, (*23)

php artisan generate:interface {interface_name}

Example

php artisan generate:interface Finance

this generates the following, (*24)

<?php

namespace App\Logic\Interfaces;

/**
*  FinanceInterface Interface
*/
interface FinanceInterface
{
    //
}

Create a Trait

We use the generate:trait artisan command. This also supports the -p or --path option to specify the directory path., (*25)

App\Logic\Traits is the default path, (*26)

php artisan generate:trait {trait_name}

Example

php artisan generate:trait Transactable

this generates the following, (*27)

<?php

namespace App\Logic\Traits;

/**
*  Transactable Trait
*/
trait Transactable 
{
    //
}

Contribution

All contributions (big or small) are highly welcomed. Send a PR, (*28)

Authors

Support

If you would love to support the continuous development and maintenance of this package, please consider buying me a coffee., (*29)

, (*30)

License

This package is open-sourced software licensed under the MIT Licence, (*31)

The Versions

15/02 2018

dev-master

9999999-dev

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Ngugi

14/02 2018

v1.0.3

1.0.3.0

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Ngugi

14/02 2018

dev-develop

dev-develop

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Ngugi

14/02 2018

v1.0.2

1.0.2.0

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Ngugi

14/02 2018

v1.0.1

1.0.1.0

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Ngugi

14/02 2018

v1.0

1.0.0.0

Command line tool to generate your classes, interfaces and traits. Aiming for your higher productivity

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Ngugi