return true;
}
public function redirectToSpotifyTrack() {
$song = $this->api->getMyCurrentTrack();
header('Location: '.$song->item->external_urls->spotify);
die();
}
}
protected function registerErrorHandling()
{
error_reporting(-1);
set_error_handler(function ($level, $message, $file = '', $line = 0) {
$this->handleError($level, $message, $file, $line);
});
set_exception_handler(function ($e) {
$this->handleException($e);
});
return true;
}
public function redirectToSpotifyTrack() {
$song = $this->api->getMyCurrentTrack();
header('Location: '.$song->item->external_urls->spotify);
die();
}
}
if (static::isCallableWithAtSign($callback) || $defaultMethod) {
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return $callback(...array_values(static::getMethodDependencies($container, $callback, $parameters)));
});
}
/**
* Call a string reference to a class using Class@method syntax.
* @param mixed ...$args
* @return mixed
*/
public static function unwrapIfClosure($value, ...$args)
{
return $value instanceof Closure ? $value(...$args) : $value;
}
/**
* Get the class name of the given parameter's type, if possible.
*
if ($container->hasMethodBinding($method)) {
return $container->callMethodBinding($method, $callback[0]);
}
return Util::unwrapIfClosure($default);
}
/**
* Normalize the given callback into a Class@method string.
*
if (static::isCallableWithAtSign($callback) || $defaultMethod) {
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return $callback(...array_values(static::getMethodDependencies($container, $callback, $parameters)));
});
}
/**
$this->buildStack[] = $className;
$pushedToBuildStack = true;
}
$result = BoundMethod::call($this, $callback, $parameters, $defaultMethod);
if ($pushedToBuildStack) {
array_pop($this->buildStack);
}
*/
protected function callControllerCallable(callable $callable, array $parameters = [])
{
try {
return $this->prepareResponse(
$this->call($callable, $parameters)
);
} catch (HttpResponseException $e) {
return $e->getResponse();
}
}
if (count($middleware) > 0) {
return $this->callLumenControllerWithMiddleware(
$instance, $method, $routeInfo, $middleware
);
} else {
return $this->callControllerCallable(
[$instance, $method], $routeInfo[2]
);
}
}
if (! method_exists($instance = $this->make($controller), $method)) {
throw new NotFoundHttpException;
}
if ($instance instanceof LumenController) {
return $this->callLumenController($instance, $method, $routeInfo);
} else {
return $this->callControllerCallable(
[$instance, $method], $routeInfo[2]
);
}
protected function callActionOnArrayBasedRoute($routeInfo)
{
$action = $routeInfo[1];
if (isset($action['uses'])) {
return $this->prepareResponse($this->callControllerAction($routeInfo));
}
foreach ($action as $value) {
if ($value instanceof Closure) {
$callable = $value->bindTo(new RoutingClosure);
return $this->callActionOnArrayBasedRoute($this['request']->route());
}));
}
return $this->prepareResponse(
$this->callActionOnArrayBasedRoute($routeInfo)
);
}
/**
* Call the Closure or invokable on the array based route.
return $this->sendThroughPipeline($this->middleware, function ($request) use ($method, $pathInfo) {
$this->instance(Request::class, $request);
if (isset($this->router->getRoutes()[$method.$pathInfo])) {
return $this->handleFoundRoute([true, $this->router->getRoutes()[$method.$pathInfo]['action'], []]);
}
return $this->handleDispatcherResponse(
$this->createDispatcher()->dispatch($method, $pathInfo)
);
->send($this->make('request'))
->through($middleware)
->then($then);
}
return $then($this->make('request'));
}
/**
* Prepare the response for sending.
*
[$method, $pathInfo] = $this->parseIncomingRequest($request);
try {
$this->boot();
return $this->sendThroughPipeline($this->middleware, function ($request) use ($method, $pathInfo) {
$this->instance(Request::class, $request);
if (isset($this->router->getRoutes()[$method.$pathInfo])) {
return $this->handleFoundRoute([true, $this->router->getRoutes()[$method.$pathInfo]['action'], []]);
}
* @param \Symfony\Component\HttpFoundation\Request|null $request
* @return void
*/
public function run($request = null)
{
$response = $this->dispatch($request);
if ($response instanceof SymfonyResponse) {
$response->send();
} else {
echo (string) $response;
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$app->run();
ErrorException
|
---|
ErrorException: Attempt to read property "item" on null at /var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/app/Http/Controllers/SpotifyController.php:99 at Laravel\Lumen\Application->handleError() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php:47) at Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/app/Http/Controllers/SpotifyController.php:99) at App\Http\Controllers\SpotifyController->redirectToSpotifyTrack() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/illuminate/container/BoundMethod.php:36) at Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/illuminate/container/Util.php:41) at Illuminate\Container\Util::unwrapIfClosure() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/illuminate/container/BoundMethod.php:93) at Illuminate\Container\BoundMethod::callBoundMethod() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/illuminate/container/BoundMethod.php:35) at Illuminate\Container\BoundMethod::call() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/illuminate/container/Container.php:661) at Illuminate\Container\Container->call() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:391) at Laravel\Lumen\Application->callControllerCallable() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:356) at Laravel\Lumen\Application->callLumenController() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:331) at Laravel\Lumen\Application->callControllerAction() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:284) at Laravel\Lumen\Application->callActionOnArrayBasedRoute() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:269) at Laravel\Lumen\Application->handleFoundRoute() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:171) at Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:431) at Laravel\Lumen\Application->sendThroughPipeline() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:167) at Laravel\Lumen\Application->dispatch() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:112) at Laravel\Lumen\Application->run() (/var/www/danielsrothstan/spotify-informer.daniels-roth-stan.fr/public/index.php:28) |