/** * Set custom script name instead of $_SERVER['SCRIPT_NAME'] used by default. * Useful for those using front controllers, when all requests are served by one PHP script. * * @param string $scriptName * @return Pinba */ public function setScriptName($scriptName) { if ($this->enabled && $scriptName) { pinba_script_name_set($scriptName); $this->fixScriptName = false; } return $this; }
public function onRequest(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { return; } if (!function_exists('pinba_script_name_set') || PHP_SAPI === 'cli') { return; } pinba_script_name_set($event->getRequest()->getRequestUri()); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $return = $next($request); if (extension_loaded('pinba')) { $route = $request->route(); if ($route) { $script_name = $route->getUri(); } else { $script_name = self::UNKNOWN_SCRIPT_NAME; } pinba_script_name_set($script_name); } return $return; }
/** * @return mixed * @throws JsonRpcException */ protected function getHandler() { if (strpos($this->getMethod(), '.') !== false) { list($object, $method) = explode(".", $this->getMethod()); $pinba_filename = $object . "_" . $method; try { $object = Yii::createObject(JsonRPCModule::getInstance()->apiNamespace . '\\' . $object); } catch (\Exception $e) { throw new JsonRpcException($e->getMessage(), JsonRpcException::METHOD_NOT_FOUND, $e); } } else { $object = 'Base'; $method = $this->getMethod(); $class = get_class($this); $namespace = ''; if (($pos = strrpos($class, '\\')) !== false) { $namespace = substr($class, 0, $pos) . '\\'; } $pinba_filename = $object . "_" . $method; $object = Yii::createObject($namespace . $object); } if (function_exists('pinba_script_name_set')) { pinba_script_name_set($pinba_filename); } $this->setMethod($method); $this->setObject($object); $class = new \ReflectionClass($this->getObject()); if (!$class->hasMethod($this->getMethod())) { throw new JsonRpcException("Method not found " . $this->getMethod(), JsonRpcException::METHOD_NOT_FOUND); } $method = $class->getMethod($this->getMethod()); return $method; }
public function setScriptName($name) { pinba_script_name_set($name); return $this; }
public static function setScriptName($scriptName) { if (self::init()) { return pinba_script_name_set($scriptName); } }
/** * @inheritdoc */ public function init() { $clientUsed = $this->getClientUsed(); if (!$this->worksWithoutPinba && $clientUsed === self::CLIENT_NONE) { throw new InvalidConfigException('Pinba functionale not available'); } parent::init(); if ($this->remindAboutTimers) { \Yii::$app->attachBehavior('pinbaTimersRemind', ['class' => TimersRemindBehavior::className(), 'pinba' => $this]); } if ($clientUsed === self::CLIENT_PHP_EXTENSION) { ini_set('pinba.enabled', true); if ($this->server) { ini_set('pinba.server', $this->server); } } if ($clientUsed !== self::CLIENT_NONE) { $request = \Yii::$app->request; if ($request->isConsoleRequest) { pinba_script_name_set((isset($_SERVER['argv'][0]) ? $_SERVER['argv'][0] : '') . ' ' . (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '')); } else { pinba_script_name_set($request->getScriptUrl() . '/' . $request->getPathInfo()); } } }