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


PHP Slim::__construct方法代码示例

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


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

示例1: __construct

 public function __construct(array $userSettings = array(), $configDirectory = 'config')
 {
     // Slim initialization
     parent::__construct($userSettings);
     $this->config('debug', false);
     $this->notFound(function () {
         $this->handleNotFound();
     });
     $this->error(function ($e) {
         $this->handleException($e);
     });
     // Config
     $this->configDirectory = __DIR__ . '/../../' . $configDirectory;
     $this->config = $this->initConfig();
     // /features
     $this->get('/features', function () {
         $features = new Features($this->config['features']);
         $this->response->headers->set('Content-Type', 'application/json');
         $this->response->setBody(json_encode($features->getFeatures()));
     });
     $this->get('/features/:id', function ($id) {
         $features = new Features($this->config['features']);
         $feature = $features->getFeature($id);
         if ($feature === null) {
             return $this->notFound();
         }
         $this->response->headers->set('Content-Type', 'application/json');
         $this->response->setBody(json_encode($feature));
     });
 }
开发者ID:narikenabilli,项目名称:generator-angular-php,代码行数:30,代码来源:Application.php

示例2:

 function __construct($config)
 {
     parent::__construct();
     $this->config = $config;
     $dsn = "{$config['db_host']}:{$config['db_port']}";
     $this->conn = new Crate\PDO\PDO($dsn, null, null, null);
 }
开发者ID:crate,项目名称:crate-sample-apps,代码行数:7,代码来源:index.php

示例3: __construct

 public function __construct(array $userSettings = array())
 {
     $this->schemaPath = $userSettings['propelToSlim']['schemaPath'];
     $this->schemaMap = new SchemaMap($this->schemaPath);
     $this->propelToSlimSettings = $userSettings['propelToSlim'];
     return parent::__construct($userSettings);
 }
开发者ID:sam-higton,项目名称:PropelToSlim,代码行数:7,代码来源:PropelToSlim.php

示例4: __construct

 public function __construct()
 {
     parent::__construct(array('mode' => getMode()));
     self::$_INSTANCE = $this;
     # add the exception middleware
     $this->add(new Exception_Middleware());
 }
开发者ID:blueskyfish,项目名称:temperature-sensor-server,代码行数:7,代码来源:Application.php

示例5: __construct

 public function __construct($config)
 {
     parent::__construct();
     $this->config = $config;
     $this->routingManager = new RoutingManager(array("cache" => dirname(__FILE__) . "/../../cache", "controllers" => dirname(__FILE__) . "/Controllers", "controller_namespace" => "App\\Controllers"));
     $this->add($this->routingManager);
 }
开发者ID:PsykoSoldi3r,项目名称:slim-doctrine-demo,代码行数:7,代码来源:App.php

示例6: __construct

 public function __construct()
 {
     $settings = (require "../settings.php");
     if (isset($settings['model'])) {
         $this->data = $settings['model'];
     }
     parent::__construct($settings);
 }
开发者ID:NicolasVillalba,项目名称:Slim-MVC,代码行数:8,代码来源:Controller.php

示例7: array

 function __construct($namespace)
 {
     parent::__construct();
     $this->config('debug', true);
     $error_handler = array($this, 'error_handler');
     $this->error($error_handler);
     $this->get('(/)', array($this, 'displayServiceDoc'));
     $this->get('/\\$metadata', array($this, 'displayMetadata'));
     $this->serviceDoc = new ODataServiceDoc();
     $this->metadataDoc = new CSDLSchema($namespace);
 }
开发者ID:pboyd04,项目名称:SlimOData,代码行数:11,代码来源:class.SlimOData.php

示例8: __construct

 public function __construct(array $userSettings = array())
 {
     $settings = array_unique(array_merge($this->defaultSettings, $userSettings));
     parent::__construct($settings);
     $this->view()->parserExtensions = array(new TwigExtension());
     $this->registerErrorHandler();
     $this->registerHooks();
     $this->registerServices();
     $this->registerControllers();
     $this->registerRoutes();
 }
开发者ID:blackout314,项目名称:paytoshi-faucet,代码行数:11,代码来源:App.php

示例9: __construct

 /**
  * @param $basePath
  */
 public function __construct($basePath)
 {
     $this->basePath = rtrim($basePath, '/');
     $dotenv = new Dotenv($this->basePath);
     $dotenv->load();
     $config = $this->loadConfigFile('config') ?: [];
     parent::__construct($config);
     $this->loadRoutes();
     $this->setupServices();
     //$this->setupErrorHandler();
     //$this->setupNotFound();
 }
开发者ID:jbennett122,项目名称:banerelle.com,代码行数:15,代码来源:Application.php

示例10: __construct

 public function __construct(array $userSettings = array())
 {
     parent::__construct($userSettings);
     $this->get('Product/Image/:id', function ($id) {
         echo "hello {$name}";
     })->name('id');
     echo '===__construct 0<br>';
     flush();
     $this->curlHandler = curl_init();
     echo '===__construct 1<br>';
     flush();
 }
开发者ID:WTer,项目名称:NJB,代码行数:12,代码来源:ProducerTest.php

示例11: __construct

 public function __construct($mode = null)
 {
     if ($mode === null) {
         $mode = $this->inferMode();
     }
     parent::__construct(array('mode' => $mode));
     call_user_func(function ($app) {
         include self::$privateDir . '/config.php';
     }, $this);
     $this->setupServices($this);
     $this->setupRoutes($this);
 }
开发者ID:tassoevan,项目名称:skeleton,代码行数:12,代码来源:Application.php

示例12: __construct

 /**
  * Register all the application services, routes and middleware
  *
  * @param  array $options Associative array of application settings
  */
 public function __construct(array $options = array())
 {
     parent::__construct($options);
     $container = new SlimContainer(new EwalletWebContainer($options, $this));
     $this->container = $container->merge($this->container);
     $resolver = new Resolver();
     $services = new Services($resolver, $options);
     $services->configure($this);
     $controllers = new Controllers($resolver);
     $controllers->register($this);
     $middleware = new Middleware();
     $middleware->configure($this);
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:18,代码来源:Application.php

示例13: __construct

 /**
  * Construct a new instance of Tacit.
  *
  * @param string|array|null $configuration An array or file that returns an
  * array when included.
  */
 public function __construct($configuration = null)
 {
     $configuration = $this->loadConfiguration($configuration);
     parent::__construct($configuration);
     $connection = $this->config('connection');
     $this->configureMode('production', function () {
         $this->config(['log.enable' => true, 'debug' => false]);
     });
     $this->configureMode('development', function () {
         $this->config(['log.enable' => false, 'debug' => true]);
     });
     if ($connection !== null) {
         $this->container->singleton('repository', function () use($connection) {
             $dbClass = $connection['class'];
             return new $dbClass($connection);
         });
     }
     $this->add(new ContentTypes());
     $this->error(function (\Exception $e) {
         $resource = ['status' => 500, 'code' => $e->getCode(), 'message' => $e->getMessage()];
         if ($e instanceof RestfulException) {
             if ($e instanceof NotFoundException) {
                 $this->notFound();
             }
             $resource['status'] = $e->getStatus();
             $resource['description'] = $e->getDescription();
             $resource['property'] = $e->getProperty();
         }
         /* @var \Slim\Http\Response $response */
         $response = $this->response;
         $response->headers->set('Content-Type', 'application/json');
         $response->setStatus($resource['status']);
         if ($this->config('debug') === true) {
             $resource['request_duration'] = microtime(true) - $this->config('startTime');
         }
         $response->setBody(json_encode($resource));
         $this->stop();
     });
     $this->notFound(function () {
         $resource = ['status' => 404, 'message' => 'Resource not found'];
         /* @var \Slim\Http\Response $response */
         $response = $this->response;
         $response->headers->set('Content-Type', 'application/json');
         $response->setStatus(404);
         if ($this->config('debug') === true) {
             $resource['request_duration'] = microtime(true) - $this->config('startTime');
         }
         $response->setBody(json_encode($resource));
         $this->stop();
     });
 }
开发者ID:vgrish,项目名称:tacit,代码行数:57,代码来源:Tacit.php

示例14: __construct

 /**
  * Constructor
  *
  * @param array $settings null
  */
 public function __construct(array $settings = null)
 {
     if (version_compare(phpversion(), '5.4.0', '<')) {
         throw new \RuntimeException('Slimore require PHP version >= 5.4.0');
     }
     require __DIR__ . "/../Helper/Functions.php";
     $settings = array_merge($this->defaults, $settings);
     if ($settings['x-framework-header']) {
         header('X-Framework-By: Slimore/' . $this->version);
     }
     parent::__construct($settings);
     date_default_timezone_set($this->config('timezone'));
     $this->init();
 }
开发者ID:im286er,项目名称:slimore,代码行数:19,代码来源:Application.php

示例15: __construct

 public function __construct($userSettings = array())
 {
     parent::__construct($userSettings);
     ZiFacade::setFacadeApplication($this);
     ZiFacade::registerAliases();
     $this->view(new \Slim\Views\Twig());
     $this->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath('zi/templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true);
     $this->view->parserExtensions = array(new \Slim\Views\TwigExtension(), new ZiTwigExtension());
     $this->container->singleton('db', function ($c) {
         return require ZICONFIG . '/database.php';
     });
     $this->setORM();
     $this->setAuth();
 }
开发者ID:suryakencana,项目名称:tekkadan,代码行数:14,代码来源:Zi.php


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