Download the PHP package lordfm/raw without Composer

On this page you can find all versions of the php package lordfm/raw. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package raw

RAW

Raw is a quick repository pattern scaffolding package for laravel. It mixes Doctrine Annotations with Eloquent ORM to handle the structure of your project from the models.

Do you have something in mind? You should be able to build it from the very bottom without suffer.

Install

composer require lordfm/raw

Add the provider to your app.php

'providers' = [
    /*
    * Lots of providers
    *
    */
    LoRDFM\Raw\RawServiceProvider::class
]

Publish the raw.php configuiration file

php artisan vendor:publish --provider="LoRDFM\Raw\RawServiceProvider"

Annotate your model

Declare the use of LoRDFM\Raw\Annotations\Rawable and add the annotation on top of your model. Be sure to not leave blank lines between the annotation and the class.

MyModel.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

use LoRDFM\Raw\Annotations\Rawable;

/**
*
* @Rawable
*/
class MyModel extends Model
{

}

Now, just run

php artisan raw:repository

What happened?. We just built our typical --resource Controller along with a Contract interface to declare all crud related methods and a Repository class to implement them.

Don't forget to bind your repositories in your Providers\AppServiceProvider.php

By default they will be stored in app\Http\Controllers, app\Repositories and app\Repositories\Contracts.

As you may be expecting, y can create complex models with relationships. We support the nex relationships

Realation Annotation
one to many @HasMany
many to one @BelongsTo
has one @HasOne

Annotations

The annotations are pretty straight forward, ech one handles the relation of the model to another model and the declaration of the files holding the repository pattern.

@Rawable

Each model you want to be handled by the package should have this annotation.

@HasMany

An array of models with related as One to Many from the current model

@HasOne

An array of models with related as One to One from the current model

@BelongsTo

An array of models with related as Many to One from the current model

@RawableContract

Handles the cration of the interface class (aka 'contract') with the methods your repository and controller should implement. This is the core of the customization of the repository @RawableController and @RawableRepository requires the namespace of this annotation as argument Supports path and a namespace to store and declare the interface

@RawableController

Handles the creation of the controllers. Supports path, namespace and contract to store and declare the --resource style controller for your model.

@RawableRepository

Handles the repository class creation. Supports path, namespace and contract to store and delcare the class

Now What?

Long story short, we are going to use a very well known example of related entities to demonstrate the use of the pluging. Classic Author -> Articles example:

Author model

<?php
namespace  App\Models;

use Illuminate\Database\Eloquent\Model;

use LoRDFM\Raw\Annotations\Rawable;
use LoRDFM\Raw\Annotations\HasMany;
use LoRDFM\Raw\Annotations\HasOne;

/**
*
* @Rawable
* @HasMany(models = {"Article"})
* @HasOne(models = {"Profile"})
*/
class  Author  extends  Model
{

    public  function  articles()
    {
        return  $this->hasMany('App\Models\Article');
    }

    public  function  profile()
    {
        return  $this->hasOne('App\Models\Profile');
    }

}

The Author holds a One to One relation to a Profilemodel nad One to Many to the Article model

Article model

<?php

namespace  App\Models;

use Illuminate\Database\Eloquent\Model;

use LoRDFM\Raw\Annotations\Rawable;
use LoRDFM\Raw\Annotations\BelongsTo;

/**
*
* @Rawable
* @BelongsTo(models = {"Author"})
*/
class  Article  extends  Model
{
    public  function  author()
    {
    return  $this->belongsTo('App\Models\Author');
    }
}

The Article holds Many to One to their author

Profile model

<?php

namespace  App\Models;

use Illuminate\Database\Eloquent\Model;

class  Profile  extends  Model
{
    public  function  author()
    {
    return  $this->belongsTo('App\Models\Author');
    }
}

The Profile model has no @Rawable implementation at all, not required for the moment.

Let's go!

Now, just run

 php artisan raw:repository

and it will tell you on wich model is working and creating its repository

...
Making repository for App\Models\Article
Making repository for App\Models\Author
...

If the repository for the model already exists you will be warned

Making repository for App\Models\Author
This Contract already exists. If you want to overwrite it use '--force'
This Repository already exists. If you want to overwrite it use '--force'
This Controller already exists. If you want to overwrite it use '--force'
This RouteGroup already exists. If you want to overwrite it use '--force'

You can overwrite them using --force

php artisan raw:repository --force

Be careful, the corresponding files will be completely overwritten. You may choose to run the command for just some models

php artisan raw:repository Author
php artisan raw:repository Author Article
php artisan raw:repository Author Article Publisher ...

Custom Structure

You can customize the contract, controller and repository for your model Just import the annotations and define them with your desired path and namespace Remember that RawableController and RawableRepository requires the namespace of their corresponding contract

<?php
namespace  App\Models;

use Illuminate\Database\Eloquent\Model;

use LoRDFM\Raw\Annotations\Rawable;
use LoRDFM\Raw\Annotations\RawableController;
use LoRDFM\Raw\Annotations\RawableContract;
use LoRDFM\Raw\Annotations\RawableRepository;
use LoRDFM\Raw\Annotations\HasMany;
use LoRDFM\Raw\Annotations\HasOne;

/**
*
* @Rawable
* @HasMany(models = {"Article"})
* @HasOne(models = {"Profile"})
*
* @RawableContract(path = "app\Repository\Contracts", namespace = "App\Repository\Contracts")
* @RawableController(path = "app\Http\Controllers", namespace = "App\Http\Controllers", contract = "App\Repository\Contracts")
* @RawableRepository(path = "app\Repository", namespace = "App\Repository", contract = "App\Repository\Contracts")
*/
class  Author  extends  Model
{

    public  function  articles()
    {
        return  $this->hasMany('App\Models\Article');
    }

    public  function  profile()
    {
        return  $this->hasOne('App\Models\Profile');
    }

}

Multiple Endpoints

You might want multiple endpoints with similar implementation, like a Guest and Api implementation for unauthenticated and authenticated users. Just define multiple groups of RawableContract, RawableController and RawableRepository Here is an example...

<?php

namespace  App\Models;

use Illuminate\Database\Eloquent\Model;

use LoRDFM\Raw\Annotations\Rawable;
use LoRDFM\Raw\Annotations\RawableController;
use LoRDFM\Raw\Annotations\RawableContract;
use LoRDFM\Raw\Annotations\RawableRepository;
use LoRDFM\Raw\Annotations\BelongsTo;

/**
*
* @Rawable
* @BelongsTo(models = {"Author"})
*
* @RawableContract(path = "app\Repository\Api\Contracts", namespace = "App\Repository\Api\Contracts")
* @RawableController(path = "app\Http\Controllers\Api", namespace = "App\Http\Controllers",  contract = "App\Repository\Api\Contracts")
* @RawableRepository(path = "app\Repository\Api", namespace = "App\Repository\Api", contract = "App\Repository\Api\Contracts")
*
* @RawableContract(path = "app\Repository\Guest\Contracts", namespace = "App\Repository\Guest\Contracts")
* @RawableController(path = "app\Http\Controllers\Guest", namespace = "App\Http\Controllers",  contract = "App\Repository\Guest\Contracts")
* @RawableRepository(path = "app\Repository\Guest", namespace = "App\Repository\Guest", contract = "App\Repository\Guest\Contracts")
*
*/
class  Article  extends  Model
{
    public  function  author()
    {
    return  $this->belongsTo('App\Models\Author');
    }
}

Test boilerplate

You can generate some Unit test boilerplate for you repository

 php artisan raw:repository --test

Gotchas


All versions of raw with dependencies

PHP Build Version
Package Version
Requires doctrine/annotations Version ^1.4
symfony/class-loader Version 2.8
icanboogie/inflector Version 1.4.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lordfm/raw contains the following files

Loading the files please wait ....