2017 © Pedro Peláez
 

library pkg-support

Support config and language classes for creating laravel packages

image

spescina/pkg-support

Support config and language classes for creating laravel packages

  • Thursday, December 4, 2014
  • by simonpex
  • Repository
  • 1 Watchers
  • 1 Stars
  • 208 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status Coverage Status, (*1)

Package Development Support

Support config and language classes for creating laravel packages, (*2)

Install && Usage

Add in the target package composer.json, (*3)

"require": {
    "spescina/pkg-support": "1.x"
}

Let the main package class implements the Spescina\PkgSupport\PackageInterface.
In the same class import the Spescina\PkgSupport\PkgTrait trait. Now the constructor has to respect the interface definition., (*4)

public function __construct(ServiceInterface $config, ServiceInterface $lang)
{
        $this->config = $config;
        $this->lang = $lang;
}

Then you should take care of these dependencies when instantiating the object, usually in the package service provider., (*5)

$this->app['mypackage'] = $this->app->share(function($app) {
        return new MyPackage(new Config('mypackage'), new Lang('mypackage'));
});

This constructor force the creation of a config and a lang object keeping the registration key for your package. With them, it will be possible to use Laravel Config and Lang facades from the package classes without having to specify the package prefix every time.
Assuming your class has a facade, you can now make these calls * MyPackage::conf() equal to Config::get('mypackage::mypackage') * MyPackage::conf('key') equal to Config::get('mypackage::mypackage.key') * MyPackage::conf('key', 'section') equal to Config::get('mypackage::section.key') * MyPackage::lang('key') equal to Lang::get('mypackage::mypackage.key') * MyPackage::lang('key', 'section') equal to Lang::get('mypackage::section.key'), (*6)

The Versions

04/12 2014

dev-master

9999999-dev

Support config and language classes for creating laravel packages

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel config package lang

04/12 2014

1.0.3

1.0.3.0

Support config and language classes for creating laravel packages

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel config package lang

15/04 2014

dev-develop

dev-develop

Support config and language classes for creating laravel packages

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel config package lang

14/04 2014

1.0.2

1.0.2.0

Support config and language classes for creating laravel packages

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel config package lang

14/04 2014

1.0.1

1.0.1.0

Support config and language classes for creating laravel packages

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel config package lang

13/04 2014

1.0.0

1.0.0.0

Support config and language classes for creating laravel packages

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel config package lang