aedart/laravel-application 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aedart/laravel-application

最新稳定版本:1.1.0

Composer 安装命令:

composer require aedart/laravel-application

包简介

Getter and Setter package for a Laravel application instance. It serves as an alternative to the app() method, found in the framework's foundation helpers file.

README 文档

README

Getter and Setter package for a Laravel application instance. It serves as an alternative to the app() method, found in the framework's foundation helpers file.

Contents

[TOC]

When to use this

When your components needs to be aware of a Laravel application instance

How to install

For Laravel version 5.0.x

#!console

composer require aedart/laravel-application 1.0.*

This package uses composer. If you do not know what that is or how it works, I recommend that you read a little about, before attempting to use this package.

Quick start

Provided that you have an interface, e.g. for a command, you can extend the application-aware interface;

#!php
<?php
use Aedart\Laravel\Application\Interfaces\ApplicationAware;

interface ICommand extends ApplicationAware {

    // ... Remaining interface implementation not shown ...
    
}

In your concrete implementation, you simple use the application-traits;

#!php
<?php
use Aedart\Laravel\Application\Traits\ApplicationTrait;

class DoSomethingCommand implements ICommand {
 
    use ApplicationTrait;

    // ... Remaining implementation not shown ... 
 
}

Default Application instance

The ApplicationTrait will by default return the current running Laravel application instance, if any is available. However, if none is available, null is returned instead.

To ensure that an application is available, before attempting to use it, please use the hasApplication() and hasDefaultApplication() methods.

Default Application Validation

By default, the ApplicationTrait will always assume that the specified application instance is valid. However, if you need to ensure that specific configuration has been set or certain service providers are available, or some other kind of application-specific validation, then you can do so, by overriding the isApplicationValid() method.

#!php
<?php
use Aedart\Laravel\Application\Traits\ApplicationTrait;

class DoSomethingCommand implements ICommand {
 
    use ApplicationTrait;

    public function isApplicationValid(Application $application){
        // In this example, we ensure that the database default driver
        // is sqlite
        $defaultDriver = $application['config']['database.default'];
        if($defaultDriver == 'sqlite'){
            return true;
        }
        
        return false;
    }

    // ... Remaining implementation not shown ... 
 
}

Acknowledgement

Taylor Otwell et al. for one of the best PHP frameworks ever created.

License

BSD-3-Clause, Read the LICENSE file included in this package

统计信息

  • 总下载量: 50
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-04-06