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


PHP Url::setStaticBaseUri方法代码示例

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


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

示例1: setUrl

 private function setUrl()
 {
     $url = new Url();
     if (!$this->application->debug) {
         $url->setBaseUri($this->application->production->baseUri);
         $url->setStaticBaseUri($this->application->production->staticBaseUri);
     } else {
         $url->setBaseUri($this->application->development->baseUri);
         $url->setStaticBaseUri($this->application->development->staticBaseUri);
     }
     return $url;
 }
开发者ID:jeins,项目名称:Phalcon-RestApi,代码行数:12,代码来源:AppService.php

示例2: onBoot

 public function onBoot()
 {
     // TODO: Implement onBoot() method.
     $this->getDI()->setShared('url', function () {
         $protocol = stripos(server('SERVER_PROTOCOL'), 'https') === true ? 'https://' : 'http://';
         $hostname = server('HTTP_HOST');
         $url = new Url();
         $url->setStaticBaseUri(env('static_url', "{$protocol}{$hostname}/"));
         $url->setBaseUri(env('base_url', '/'));
         return $url;
     });
 }
开发者ID:dotronglong,项目名称:phalcon-engine,代码行数:12,代码来源:ServiceRegister.php

示例3: setUrlService

 /**
  * Set url service when module start
  * @param Di $di
  * @param Config $config
  * @param string $name Module name
  * @return \Phalex\Events\Listener\Application
  */
 private function setUrlService(Di $di, Config $config, $name)
 {
     $base = $static = '/';
     if (isset($config['url'])) {
         $default = isset($config['url']['default']) ? $config['url']['default'] : '/';
         if (isset($config['url'][$name])) {
             $base = isset($config['url'][$name]['uri']) ? $config['url'][$name]['uri'] : $default;
             $static = isset($config['url'][$name]['static']) ? $config['url'][$name]['static'] : $default;
         }
     }
     $url = new UrlService();
     $url->setBaseUri($base);
     $url->setStaticBaseUri($static);
     $di->set('url', $url, true);
     return $this;
 }
开发者ID:tmquang6805,项目名称:phalex,代码行数:23,代码来源:Application.php

示例4: function

//Github API mock
$di->set('github', function () use($config) {
    $api = m::mock("api");
    $api->shouldReceive("show")->with("simple-helpers", "php-file-mover", 8)->andReturn(json_decode(file_get_contents(__DIR__ . "/../_data/8"), true));
    $client = m::mock("Github");
    $client->shouldReceive("api")->with('pull_request')->andReturn($api);
    return $client;
}, true);
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function () use($config) {
    $url = new UrlResolver();
    if (!$config->application->debug) {
        $url->setBaseUri($config->application->production->baseUri);
        $url->setStaticBaseUri($config->application->production->staticBaseUri);
    } else {
        $url->setBaseUri($config->application->development->baseUri);
        $url->setStaticBaseUri($config->application->development->staticBaseUri);
    }
    return $url;
}, true);
/**
 * Database connection is created based in the parameters defined in the configuration file
 */
$di->set('db', function () use($config) {
    $connection = new DatabaseConnection($config->database->toArray());
    $debug = $config->application->debug;
    if ($debug) {
        $eventsManager = new EventsManager();
        $logger = new FileLogger(APP_PATH . "/app/logs/db.log");
开发者ID:simple-helpers,项目名称:php-github-api-wrap,代码行数:31,代码来源:services.php

示例5: setStaticBaseUri

 public function setStaticBaseUri($staticBaseUri)
 {
     return parent::setStaticBaseUri($staticBaseUri);
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:4,代码来源:Url.php

示例6: FactoryDefault

use Phalcon\Session\Adapter\Files as SessionAdapter;
/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * Set router for rewrite url
 */
$di->setShared('router', include __DIR__ . '/routers.php');
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->setShared('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    $url->setStaticBaseUri($config->application->staticUri);
    return $url;
});
/**
 * Setting up the view component
 */
$di->setShared('view', function () use($config) {
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
    $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '.'));
        return $volt;
    }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
    return $view;
});
开发者ID:tienrocker,项目名称:phalcon_mvc_modular,代码行数:31,代码来源:services.php

示例7: registerServices

 /**
  * Register the services here to make them general
  * or register in the ModuleDefinition to make them module-specific
  */
 public function registerServices(DiInterface $di)
 {
     //Read configuration
     $config = (include __DIR__ . "/config/config.php");
     $configGlobal = $di->getConfig();
     $di->set('url', function () use($config, $configGlobal) {
         $url = new Url();
         if (APPLICATION_ENV == 'production') {
             $url->setStaticBaseUri($configGlobal->application->production->staticBaseUri);
         } else {
             $url->setStaticBaseUri($configGlobal->application->development->staticBaseUri);
         }
         $url->setBaseUri($config->application->baseUri);
         return $url;
     });
     //Registering a dispatcher
     $di->set('dispatcher', function () {
         $eventsManager = $this->getEventsManager();
         $eventsManager->attach("dispatch", function ($event, $dispatcher, $exception) {
             //controller or action doesn't exist
             if ($event->getType() == 'beforeException') {
                 $message = $exception->getMessage();
                 $response = $this->getResponse();
                 switch ($exception->getCode()) {
                     case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                         $response->redirect();
                         return false;
                     case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                         $response->redirect('action-not-found?msg=' . $message);
                         return false;
                     case Dispatcher::EXCEPTION_CYCLIC_ROUTING:
                         $response->redirect('cyclic-routing?msg=' . $message);
                         return false;
                 }
             }
         });
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Phanbook\\Frontend\\Controllers");
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     });
     /**
      * Setting up the view component
      */
     $di->set('view', function () use($di) {
         $config = $di->get('config');
         $view = new View();
         $view->setViewsDir(ROOT_DIR . 'content/themes/' . $config->theme);
         $view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);
         $view->registerEngines(['.volt' => 'volt']);
         // Create an event manager
         $eventsManager = $this->getEventsManager();
         $eventsManager->attach('view', function ($event, $view) {
             if ($event->getType() == 'notFoundView') {
                 throw new \Exception('View not found!!! (' . $view->getActiveRenderPath() . ')');
             }
         });
         // Bind the eventsManager to the view component
         $view->setEventsManager($eventsManager);
         return $view;
     });
 }
开发者ID:SidRoberts,项目名称:phanbook,代码行数:66,代码来源:Module.php

示例8: initUrl

 /**
  * Initialize the Url service.
  *
  * The URL component is used to generate all kind of urls in the application.
  *
  * @param DiInterface   $di     Dependency Injector
  * @param Config        $config App config
  * @param EventsManager $em     Events Manager
  *
  * @return void
  */
 protected function initUrl(DiInterface $di, Config $config, EventsManager $em)
 {
     $di->setShared('url', function () use($config) {
         $url = new UrlResolver();
         if (ENV_PRODUCTION === APPLICATION_ENV) {
             $url->setBaseUri($config->get('application')->production->baseUri);
             $url->setStaticBaseUri($config->get('application')->production->staticBaseUri);
         } else {
             $url->setBaseUri($config->get('application')->development->baseUri);
             $url->setStaticBaseUri($config->get('application')->development->staticBaseUri);
         }
         return $url;
     });
 }
开发者ID:huoybb,项目名称:forum,代码行数:25,代码来源:Bootstrap.php

示例9: initUrl

 /**
  * Initializes the baseUrl
  *
  * @param array $options
  */
 public function initUrl($options = [])
 {
     $config = $this->di['config'];
     $request = $this->di['request'];
     /**
      * The URL component is used to generate all kind of urls in the
      * application
      */
     $this->di->setShared('url', function () use($config, $request) {
         $url = new PhUrl();
         if (SUBDOMAIN == 'm') {
             $config->app_baseUri = 'm.' . $config->app_baseUri;
         }
         $url->setBaseUri($request->getScheme() . '://' . $config->app_baseUri . '/');
         $url->setStaticBaseUri($request->getScheme() . '://' . $config->app_resourceUri . '/');
         return $url;
     });
 }
开发者ID:aisuhua,项目名称:phalcon-jumpstart,代码行数:23,代码来源:Bootstrap.php

示例10: _initEnvironment

 /**
  * Init environment.
  *
  * @param DI     $di     Dependency Injection.
  * @param Config $config Config object.
  *
  * @return Url
  */
 protected function _initEnvironment($di, $config)
 {
     set_error_handler(function ($errorCode, $errorMessage, $errorFile, $errorLine) {
         throw new \ErrorException($errorMessage, $errorCode, 1, $errorFile, $errorLine);
     });
     set_exception_handler(function ($e) use($di) {
         /**
          * Write to log when app in production mode.
          */
         if (ENV == ENV_PRODUCTION) {
             $errorId = EnException::logException($e);
         }
         if ($di->get('app')->isConsole()) {
             echo 'Error <' . $errorId . '>: ' . $e->getMessage();
             return true;
         }
         if (ENV == ENV_DEVELOPMENT) {
             $p = new PrettyExceptions($di);
             $p->setBaseUri('/plugins/pretty-exceptions/');
             return $p->handleException($e);
         }
         return true;
     });
     if ($config->global->profiler) {
         $profiler = new EnProfiler();
         $di->set('profiler', $profiler);
     }
     /**
      * The URL component is used to generate all kind of urls in the
      * application
      */
     $url = new PhUrl();
     $url->setBaseUri($config->global->baseUrl);
     $url->setStaticBaseUri($config->global->staticUrl);
     $di->set('url', $url);
     return $url;
 }
开发者ID:nguyenducduy,项目名称:haraapp,代码行数:45,代码来源:Init.php

示例11: Loader

$loader = new Loader();
// Register the Library namespace as well as the common module
// since it needs to always be available
$loader->registerNamespaces(['Phalcon\\Test\\Models' => $config->get('application')->modelsDir, 'Phalcon\\Test\\Collections' => $config->get('application')->collectionsDir, 'Phalcon\\Test\\Modules\\Frontend\\Controllers' => $config->get('application')->modulesDir . 'frontend/controllers/', 'Phalcon\\Test\\Modules\\Backend\\Controllers' => $config->get('application')->modulesDir . 'backend/controllers/']);
$loader->registerDirs([$config->get('application')->controllersDir, $config->get('application')->tasksDir, $config->get('application')->microDir]);
$loader->register();
$di->setShared('loader', $loader);
/**
 * The URL component is used to generate all kind of urls in the
 * application
 */
$di->setShared('url', function () use($di) {
    $config = $di['config'];
    $config = $config->get('application');
    $url = new Url();
    $url->setStaticBaseUri($config->staticUri);
    $url->setBaseUri($config->baseUri);
    return $url;
});
/**
 * Router
 */
$di->setShared('router', function () {
    return new Router(false);
});
/**
 * Dispatcher
 */
$di->set('dispatcher', function () use($di) {
    return new Dispatcher();
});
开发者ID:phalcon,项目名称:cphalcon,代码行数:31,代码来源:bootstrap.php

示例12: initUrl

 protected function initUrl()
 {
     $config = $this->di['config'];
     $this->di->set('url', function () use($config) {
         $url = new UrlResolver();
         $url->setBaseUri($config->paths->baseUri);
         $url->setStaticBaseUri($config->paths->assetUri);
         return $url;
     }, TRUE);
 }
开发者ID:NavinPanchu,项目名称:phalcon-boilerplate,代码行数:10,代码来源:Base.php

示例13: initUrl

 /**
  * Initialize the Url service.
  *
  * The URL component is used to generate all kind of urls in the application.
  */
 protected function initUrl()
 {
     $this->di->setShared('url', function () {
         /** @var DiInterface $this */
         $config = $this->getShared('config');
         $url = new UrlResolver();
         if (ENV_PRODUCTION === APPLICATION_ENV) {
             $url->setBaseUri($config->get('application')->production->baseUri);
             $url->setStaticBaseUri($config->get('application')->production->staticBaseUri);
         } else {
             $url->setBaseUri($config->get('application')->development->baseUri);
             $url->setStaticBaseUri($config->get('application')->development->staticBaseUri);
         }
         return $url;
     });
 }
开发者ID:phalcon,项目名称:forum,代码行数:21,代码来源:Bootstrap.php


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