当前位置: 首页>>代码示例>>PHP>>正文


PHP App::singleton方法代码示例

本文整理汇总了PHP中App::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP App::singleton方法的具体用法?PHP App::singleton怎么用?PHP App::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->package('leeb/jsonrpc');
     \App::bind('Leeb\\Jsonrpc\\Interfaces\\RequestInterface', function ($app, $data) {
         return new \Leeb\Jsonrpc\Request($data[0]);
     });
     \App::bind('Leeb\\Jsonrpc\\JsonrpcResponse', function ($app, $data) {
         return new \Leeb\Jsonrpc\JsonrpcResponse($data[0], $data[1], $data[2]);
     });
     \App::singleton('Leeb\\Jsonrpc\\Interfaces\\JsonrpcResponseBuilderInterface', 'Leeb\\Jsonrpc\\JsonrpcResponseBuilder');
     \App::bind('Leeb\\Jsonrpc\\RoutableRequest', function ($app, $data) {
         $resolver = \App::make('Leeb\\Jsonrpc\\Interfaces\\MethodResolverInterface');
         $response_builder = \App::make('Leeb\\Jsonrpc\\Interfaces\\JsonrpcResponseBuilderInterface');
         return new \Leeb\Jsonrpc\RoutableRequest($resolver, $response_builder, $data[0]);
     });
     \App::bind('Leeb\\Jsonrpc\\JsonrpcError', function ($app, $data) {
         return new \Leeb\Jsonrpc\JsonrpcError($data[0], $data[1], $data[2], $data[3]);
     });
     \App::bind('Leeb\\Jsonrpc\\RoutableNotification', function ($app, $data) {
         $resolver = \App::make('Leeb\\Jsonrpc\\Interfaces\\MethodResolverInterface');
         return new \Leeb\Jsonrpc\RoutableNotification($resolver, $data[0]);
     });
     \App::bind('Leeb\\Jsonrpc\\RoutableBatch', function ($app, $data) {
         return new \Leeb\Jsonrpc\RoutableBatch($data[0]);
     });
     \App::singleton('Leeb\\Jsonrpc\\Interfaces\\RouterInterface', 'Leeb\\Jsonrpc\\Router');
     \App::singleton('Leeb\\Jsonrpc\\Interfaces\\MethodResolverInterface', 'Leeb\\Jsonrpc\\MethodResolver');
     \App::singleton('Leeb\\Jsonrpc\\Interfaces\\JsonrpcConfigurationInterface', 'Leeb\\Jsonrpc\\JsonrpcConfiguration');
     \App::singleton('Leeb\\Jsonrpc\\Interfaces\\RequestValidatorInterface', 'Leeb\\Jsonrpc\\RequestValidator');
     \App::singleton('Leeb\\Jsonrpc\\Interfaces\\RawRequestInterpreterInterface', 'Leeb\\Jsonrpc\\RawRequestInterpreter');
 }
开发者ID:emayk,项目名称:jsonrpc,代码行数:36,代码来源:JsonrpcServiceProvider.php

示例2: registerGithub

 /**
  * Register the GitHub class.
  *
  * @param  App  $app
  * @return null
  */
 protected function registerGithub($app)
 {
     $app->singleton('github', function ($app) {
         $config = $app['config'];
         $factory = $app['github.factory'];
         return new Github($config, $factory);
     });
     $app->alias('github', 'Caffeinated\\Github\\Github');
 }
开发者ID:caffeinated,项目名称:github,代码行数:15,代码来源:GithubServiceProvider.php

示例3: setupShortCodes

 public static function setupShortCodes()
 {
     App::singleton('shortCodeEngine', function () {
         $shortCodeEngine = new ShortCodeEngine();
         return $shortCodeEngine;
     });
     $shortCodeEngine = App::make('shortCodeEngine');
     $shortCodes = (require app_path('lib/shortcodes.php'));
     $shortCodeEngine->loadShortCodes($shortCodes);
 }
开发者ID:ramialcheikh,项目名称:onepathnetwork,代码行数:10,代码来源:BaseController.php

示例4: register

 /**
  * Register the binding
  *
  * @return void
  */
 public function register()
 {
     \App::singleton('Doctrine\\ORM\\EntityManager', function () {
         $isDevMode = true;
         $paths = array(__DIR__ . '/Infrastructure/Repository/Metadata');
         $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
         $conn = array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'laravelddd', 'user' => 'root', 'password' => 'root');
         return \Doctrine\ORM\EntityManager::create($conn, $config);
     });
 }
开发者ID:svenhartmann,项目名称:laravel-ddd,代码行数:15,代码来源:MyAppServiceProvider.php

示例5: __construct

 private function __construct($classname)
 {
     if ($lastnspos = strripos($classname, '\\')) {
         $namespace = substr($classname, 0, $lastnspos);
         $classname = substr($classname, $lastnspos + 1);
         $this->view['directory'] = $this->view['class'] = strtolower(str_replace('Controller', '', $classname));
         $namespace = explode('\\', $namespace);
         $this->view['app'] = $namespace[0];
         $this->view['module'] = $namespace[1];
     }
     $this->lean = $this->app = App::singleton();
 }
开发者ID:arkaindas,项目名称:Lean,代码行数:12,代码来源:View.php

示例6: testAppBindSingleton

 public function testAppBindSingleton()
 {
     $app = app();
     App::singleton('tmp', function ($app) {
         $var = new stdClass();
         $var->total = 10;
         return $var;
     });
     $cart1 = App::make('tmp');
     $cart2 = App::make('tmp');
     $this->assertEquals(10, $cart1->total);
     $this->assertEquals(10, $cart2->total);
     $this->assertEquals($cart1, $cart2);
 }
开发者ID:pda-code,项目名称:eshop-angular-laravel,代码行数:14,代码来源:Application.php

示例7: logTrail

 public static function logTrail($input)
 {
     try {
         $currentString = \App::make('logTrail');
     } catch (\Exception $e) {
         \App::singleton('logTrail', 'stdClass');
         $currentString = \App::make('logTrail');
         $currentString->log = [];
     }
     if (is_array($input) || is_string($input)) {
         array_push($currentString->log, $input);
     } else {
         Log::info($input);
     }
 }
开发者ID:revolverobotics,项目名称:tools-laravel-microservice,代码行数:15,代码来源:RRHelper.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     if ($header = $request->header('Authorization')) {
         $access_token_array = sscanf($header, 'Bearer %s');
         if ($access_token = $access_token_array[0]) {
             try {
                 $token = \Firebase\JWT\JWT::decode($access_token, env('APP_KEY', ''), array('HS512'));
             } catch (\Firebase\JWT\ExpiredException $e) {
                 return ['error' => true, 'code' => 'token_expired', 'message' => ['Token expired']];
             } catch (\Exception $e) {
                 return ['error' => true, 'code' => 'token_invalid', 'message' => ['Token invalid']];
             }
             \App::singleton('JWTToken', 'stdClass');
             $jwttoken = \App::make('JWTToken');
             $jwttoken->token = $token;
         } else {
             return ['error' => true, 'code' => 'token_absent', 'message' => ['Token is missing']];
         }
     } else {
         return ['error' => true, 'code' => 'token_absent', 'message' => ['Token is missing']];
     }
     return $next($request);
 }
开发者ID:altiva,项目名称:altiva-jwt,代码行数:30,代码来源:Middleware.php

示例9: exit

            $admin_locale = Config::get('app.admin_default_locale');
        }
    }
}
$language = null;
$admin_language = null;
if (!App::runningInConsole()) {
    $language = \Neonbug\Common\Models\Language::getByLocale($locale);
    if ($language == null) {
        exit('Language not found');
    }
    $admin_language = $admin_locale == $locale ? $language : \Neonbug\Common\Models\Language::getByLocale($admin_locale);
    if ($admin_language == null) {
        exit('Language not found');
    }
}
App::singleton('Language', function () use($language) {
    return $language;
});
App::singleton('AdminLanguage', function () use($admin_language) {
    return $admin_language;
});
App::singleton('LanguageRepository', '\\Neonbug\\Common\\Repositories\\LanguageRepository');
//frontend
Route::group(['middleware' => ['online']], function () use($locale) {
    Route::get('/', 'HomeController@index');
    //special route without locale prefix
    Route::group(['prefix' => $locale], function () {
        Route::get('/', 'HomeController@index');
    });
});
开发者ID:neonbug,项目名称:meexo,代码行数:31,代码来源:routes.php

示例10: post

        });
    });
    post('upload/file', 'FileController@uploadFile');
    get('download/{id}', 'FileController@getDownload');
    Route::resource('project', 'ProjectController');
    Route::resource('clients', 'ClientController');
    Route::resource('role', 'RoleController');
});
App::bind('App\\Services\\Interfaces\\SendMailInterface', 'App\\Services\\SESSendMail');
/* Routes for desktop and mobile apps */
Route::group(['prefix' => 'rest'], function () {
    post('get-timeentries-by-uid', 'RestController@getTimeEntryByUid');
    post('auth', 'RestController@login');
    get('projects', 'RestController@getProjectList');
    get('tags', 'RestController@getTags');
    post('timesheet/save', 'RestController@save');
    post('timesheet/delete', 'RestController@deleteTimeEntry');
    post('timesheet/sync-timesheets', 'RestController@syncTimesheets');
});
/************************************  OAUTH  ***********************************************/
/* Routes for oauth */
post('oauth/token', 'Auth\\OAuthController@getOAuthToken');
//oauth singleton object
App::singleton('oauth2', function () {
    $storage = new OAuth2\Storage\Pdo(array('dsn' => 'mysql:dbname=' . env('DB_DATABASE') . ';host=' . env('DB_HOST'), 'username' => env('DB_USERNAME'), 'password' => env('DB_PASSWORD')));
    $server = new OAuth2\Server($storage, array('access_lifetime' => env('ACCESS_TOKEN_LIFETIME')));
    $server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
    $server->addGrantType(new App\Http\Controllers\Auth\DesktopAppGrantType($storage));
    $server->addGrantType(new OAuth2\GrantType\RefreshToken($storage, ['always_issue_new_refresh_token' => true]));
    return $server;
});
开发者ID:snehachavan21,项目名称:timesheet,代码行数:31,代码来源:routes.php

示例11: function

|
*/
App::down(function () {
    return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
App::singleton('bugsnag', function () {
    $bugsnag = new Bugsnag_Client(Config::get('app.bugsnag_api_key'));
    $bugsnag->setReleaseStage(App::environment());
    return $bugsnag;
});
App::error(function ($exception) {
    App::make('bugsnag')->notifyException($exception, null, "error");
});
App::fatal(function ($exception) {
    App::make('bugsnag')->notifyException($exception, null, "error");
});
App::make('bugsnag')->setUser(['email' => Auth::check() ? Auth::user()->email : 'Guest user']);
App::make('bugsnag')->setBeforeNotifyFunction(function ($error) {
    $error->setMetaData(["user" => ["username" => Auth::check() ? Auth::user()->username : 'Guest user'], "metrics" => ["Metric 1" => "Some data here"]]);
});
require app_path() . '/filters.php';
开发者ID:Whyounes,项目名称:bugsnag_demo,代码行数:31,代码来源:global.php

示例12: __construct

| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
class Mailer
{
}
class RegisterUsers
{
    protected $mailer;
    public function __construct(Mailer $mailer)
    {
        $this->mailer = $mailer;
    }
    public function setMailer(Mailer $mailer)
    {
        $this->mailer = $mailer;
    }
}
App::bind('foo', function () {
    return new RegisterUsers(new Mailer());
});
App::singleton('bar', function () {
    return new RegisterUsers(new Mailer());
});
$one = app('bar');
$two = app('bar');
var_dump($one, $two);
Route::get('/', function (RegisterUsers $sth) {
    return view('welcome');
});
开发者ID:Tabrizian,项目名称:GetStarted,代码行数:31,代码来源:routes.php

示例13: function

<?php

/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    App::singleton('customURL', function () {
        //$customURL = 'http://kalugdanresort.com/public/';
        $customURL = '/';
        return $customURL;
    });
    // If you use this line of code then it'll be available in any view
    // as $site_settings but you may also use app('site_settings') as well
    View::share('customURL', app('customURL'));
});
App::after(function ($request, $response) {
    //
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
开发者ID:jhunel2389,项目名称:baeyaya-dev,代码行数:31,代码来源:filters.php

示例14: register

 /**
  * Register bindings in the container.
  *
  * @return void
  */
 public function register()
 {
     \App::singleton('actingModel', function () {
         return new \App\Facades\ActingModel();
     });
 }
开发者ID:slice-beans,项目名称:cqs-framework,代码行数:11,代码来源:ActingServiceProvider.php

示例15: function

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
App::singleton('oauth2', function () {
    $storage = new OAuth2\Storage\Pdo(array('dsn' => 'mysql:dbname=insantani;host=localhost', 'username' => 'root', 'password' => ''));
    $server = new OAuth2\Server($storage);
    $server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
    $server->addGrantType(new OAuth2\GrantType\UserCredentials($storage));
    $server->addGrantType(new OAuth2\GrantType\RefreshToken($storage));
    $server->setScopeUtil(new OAuth2\Scope(array('supported_scopes' => array('read', 'write'))));
    return $server;
});
Route::get('/', function () {
    return view('welcome');
});
Route::get('api/products', ['uses' => 'ProductController@products', 'middleware' => 'products']);
Route::get('api/products/{id}', array('uses' => 'ProductController@productDetail', 'middleware' => 'products'))->where('id', '[0-9]+');
Route::get('api/products/{id}/picture', array('uses' => 'ProductController@showPicture', 'middleware' => 'products'))->where('id', '[0-9]+');
Route::get('api/feed', ['uses' => 'ArticleController@articles', 'middleware' => 'articles']);
Route::get('api/search/product/{query}', array('uses' => 'SearchController@searchProduct', 'middleware' => 'products'))->where('query', '.+');
Route::get('api/search/tag/{query}', array('uses' => 'SearchController@searchTags', 'middleware' => 'articles'))->where('query', '.+');
Route::get('api/feed/article/{id}', array('uses' => 'ArticleController@articleDetail', 'middleware' => 'articles'))->where('id', '[0-9]+');
Route::get('api/feed/article/{id}/picture', array('uses' => 'ArticleController@showPicture', 'middleware' => 'articles'))->where('id', '[0-9]+');
开发者ID:Insantani,项目名称:SourceTree-diovi,代码行数:30,代码来源:routes.php


注:本文中的App::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。