PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 11, 2022

[FIXED] Laravel app::call('SomeController@method') not working

 March 11, 2022     laravel, laravel-5, php     No comments   

Issue

I want to be able to call a method inside a controller in the following manner:

App::call('SomeController@method');

I figured it happens like this when defining a route:

Route::get('/route', 'SomeController@method');

So maybe there's an underlying mechanism I can use more generally in my code on other places in the project, turns out there is (App::call()).

The problem I'm running into is that this generates an error:

ReflectionException (-1)
Class SomeController does not exist

## \vendor\laravel\framework\src\Illuminate\Container\Container.php

public function build($concrete)
{
    // If the concrete type is actually a Closure, we will just execute it and
    // hand back the results of the functions, which allows functions to be
    // used as resolvers for more fine-tuned resolution of these objects.
    if ($concrete instanceof Closure) {
        return $concrete($this, $this->getLastParameterOverride());
    }

    $reflector = new ReflectionClass($concrete);

    // If the type is not instantiable, the developer is attempting to resolve
    // an abstract type such as an Interface of Abstract Class and there is
    // no binding registered for the abstractions so we need to bail out.
    if (! $reflector->isInstantiable()) {
        return $this->notInstantiable($concrete);
    }

    $this->buildStack[] = $concrete;

    $constructor = $reflector->getConstructor();

I'm pretty sure I must include some stuff somewhere but since Laravel is pretty big I'm asking this community.


Solution

Try giving the full namespace like:

App::call('App\Http\Controllers\SomeController@method');


Answered By - Sapnesh Naik
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing