All Projects → Mombuyish → Laravel Oh Generators

Mombuyish / Laravel Oh Generators

This package extends the core file generators that are included with Laravel 5 or later.

Projects that are alternatives of or similar to Laravel Oh Generators

Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (+226.04%)
Mutual labels:  laravel, transformer
Swaggen
OpenAPI/Swagger 3.0 Parser and Swift code generator
Stars: ✭ 385 (+301.04%)
Mutual labels:  parser, formatter
Laravel Code Style
Automatic code formatting for Laravel projects
Stars: ✭ 344 (+258.33%)
Mutual labels:  laravel, formatter
Graphql Parser
A graphql query language and schema definition language parser and formatter for rust
Stars: ✭ 203 (+111.46%)
Mutual labels:  parser, formatter
Laravel Responder
A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.
Stars: ✭ 673 (+601.04%)
Mutual labels:  laravel, transformer
Posthtml
PostHTML is a tool to transform HTML/XML with JS plugins
Stars: ✭ 2,737 (+2751.04%)
Mutual labels:  parser, transformer
Sh
A shell parser, formatter, and interpreter with bash support; includes shfmt
Stars: ✭ 4,343 (+4423.96%)
Mutual labels:  parser, formatter
Godot Gdscript Toolkit
Independent set of GDScript tools - parser, linter and formatter
Stars: ✭ 214 (+122.92%)
Mutual labels:  parser, formatter
Globalize
A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
Stars: ✭ 4,612 (+4704.17%)
Mutual labels:  parser, formatter
Stream Parser
⚡ PHP7 / Laravel Multi-format Streaming Parser
Stars: ✭ 391 (+307.29%)
Mutual labels:  parser, laravel
Php Textile
Textile markup language parser for PHP
Stars: ✭ 200 (+108.33%)
Mutual labels:  parser, formatter
Sqlformat
.NET SQL Parser and Formatter Tool and SSMS Plugin
Stars: ✭ 49 (-48.96%)
Mutual labels:  parser, formatter
Proto
parser for Google ProtocolBuffers definition
Stars: ✭ 359 (+273.96%)
Mutual labels:  parser, formatter
Verible
Verible is a suite of SystemVerilog developer tools, including a parser, style-linter, and formatter.
Stars: ✭ 384 (+300%)
Mutual labels:  parser, formatter
Google Libphonenumber
The up-to-date and reliable Google's libphonenumber package for node.js.
Stars: ✭ 984 (+925%)
Mutual labels:  parser, formatter
Laravel Graphql
GraphQL implementation with power of Laravel
Stars: ✭ 56 (-41.67%)
Mutual labels:  laravel, transformer
Laravel Email Confirmation
Add email confimation to Laravel project
Stars: ✭ 94 (-2.08%)
Mutual labels:  laravel
Duckling old
Deprecated in favor of https://github.com/facebook/duckling
Stars: ✭ 1,332 (+1287.5%)
Mutual labels:  parser
Admin One Laravel Dashboard
Admin One — Free Laravel Dashboard (Bulma Buefy Vue.js SPA)
Stars: ✭ 94 (-2.08%)
Mutual labels:  laravel
Laravel Scavenger
The most integrated web scraper package for Laravel.
Stars: ✭ 91 (-5.21%)
Mutual labels:  laravel

Laravel Oh Generators

Build Status Total Downloads Latest Stable Version License License

This package extends the core file generators that are included with Laravel 5 or later.

Requirement

PHP >= 7

Laravel >= 5

  • 5.4 before using branch 1.1.x
  • 5.5 ~ 5.7 using branch 2.0.x
  • 5.8 - 8.x using branch 3.x.x

Installation

Install via composer

$ composer require yish/generators

Registing Service Provider

If you are using laravel 5.5 or later, you can use auto discover, you don't need put in service provider to app.php.

<?php
//app.php
'providers' => [
    \Yish\Generators\GeneratorsServiceProvider::class,
],

Generating Service

It can be generating class service.

$ php artisan make:service UserService
<?php
namespace App\Services;

use Yish\Generators\Foundation\Service\Service;

class UserService
{
    protected $repository;

    //
}

Also, it supports abstract service. You should inject your repository or model and then use it.

all()
create($attributes)
first()
firstBy($column, $value)
find($id)
findBy($column, $value)
get()
getBy($column, $value)
update($id, $attributes)
updateBy($column, $value, $attributes)
destroy($id)
destroyBy($column, $value)
paginate($page = 12)
paginateBy($column, $value, $page = 12)

Generating Repository

It can be generating class repository.

$ php artisan make:repository UserRepository
<?php
namespace App\Repositories;

use Yish\Generators\Foundation\Repository\Repository;

class UserRepository
{
    protected $model;

    //
}

Also, it supports abstract repository. You should inject your model and then use it.

all($columns = ['*'])
create($attributes)
update($id, array $attributes, array $options = [])
updateBy($column, $value, array $attributes = [], array $options = [])
first($columns = ['*'])
firstBy($column, $value, $columns = ['*'])
find($id, $columns = ['*'])
findBy($column, $value, $columns = ['*'])
get($columns = ['*'])
getBy($column, $value, $columns = ['*'])
destroy($ids)
destroyBy($column, $value)
paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
paginateBy($column, $value, $perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

Generating Transformer

It can be generating class transformer.

$ php artisan make:transformer UserTransformer

Support

TransformContract

<?php
namespace Yish\Generators\Foundation\Transform;
interface TransformContract
{
    public function transform($attributes);
}

Helper / transformer()

// $instance => Transformer class.
// $attributes => Need transform data, maybe array or collection etc.
transformer(UserTransformer::class, $data);

Generating Formatter

It can be generating class formatter.

$ php artisan make:formatter UserFormatter
<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;

class PostFormatter implements FormatContract
{
    public function format(Request $request, $items = [], $message = '', $status = 200)
    {
        //
    }
}

Support

FormatContract

<?php
namespace Yish\Generators\Foundation\Format;
use Illuminate\Http\Request;
interface FormatContract
{
    public function format(Request $request, $items = []);
}

Statusable

You can use Statusable trait to help you faster building formalize format. Set property $status = true, you can get success format. $status must be boolean, if not you will get exception.

<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;

class PostFormatter implements FormatContract
{
    use Statusable;

    protected $status = true;
}

If not, you can set false to get failed format.

<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;

class PostFormatter implements FormatContract
{
    use Statusable;
    
    protected $status = false;
}

If you need customize message, you can do:

<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;

class PostFormatter implements FormatContract
{
    use Statusable;
    
    protected $status = false;
    
    public function message()
    {
        return 'hello world'.
    }
}

Or you can customize status code, you can do:

<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;
use Yish\Generators\Foundation\Format\Formatter;

class Success extends Formatter implements FormatContract
{
   use Statusable;

    protected $status = false;

    public function code()
    {
        return Response::HTTP_ACCEPTED;
    }
}

If you need to customize what you need, check out Yish\Generators\Foundation\Format\Statusable get more detail.

Helper / formatter()

// $request => Must instance of `Illuminate\Http\Request`.
// $instance => Formatter class.
// $items => data.
formatter(request(), UserFormatter::class, $data);

Generating Presenter

It can be generating class presenter.

$ php artisan make:presenter UserPresenter
<?php

namespace App\Presenters;

class UserPresenter
{
    //
}

Generating Foundation

It can be generating class foundation.

$ php artisan make:foundation Taggable
<?php

namespace App\Foundation;

class Taggable
{
  //
}

Generating Transport

It can be generating class transport.

$ php artisan make:transport UserTransport
<?php

namespace App\Transports;

class UserTransport
{
  //
}

Generating Parser

It can be generating class parser.

$ php artisan make:parser UserParser
<?php

namespace App\Parsers;

use Yish\Generators\Foundation\Parser\Parser;

class UserParser extends Parser
{
    public function parse(array $items)
    {
        return parent::parse($items);
    }

    public function keys()
    {
        return [
            'name',
            'ages',
            'location'
        ];
    }
}
$parser = app(UserParser::class)->parse(['Yish', 30, 'Taipei']);
// ['name' => 'Yish', 'ages' => 30, 'location' => 'Taipei'];

Generating Response

It can be generating class response.

$ php artisan make:response UserResponse
<?php
namespace App\Responses;
use Illuminate\Contracts\Support\Responsable;
class UserResponse implements Responsable
{
    public function toResponse($request)
    {
        //
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].