Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向不同控制器发出的Laravel模块化请求_Php_Laravel - Fatal编程技术网

Php 向不同控制器发出的Laravel模块化请求

Php 向不同控制器发出的Laravel模块化请求,php,laravel,Php,Laravel,我正在使用一个名为mnabialek/laravelmodular的github项目。该软件包工作正常,但我无法将请求传递到不同模块中的不同控制器。我该怎么做呢 测试模块控制器 <?php namespace App\Modules\TestModule\Http\Controllers; use App\Http\Requests; use App\Http\Controllers\Controller; use Illuminate\Http\Response; use App\M

我正在使用一个名为mnabialek/laravelmodular的github项目。该软件包工作正常,但我无法将请求传递到不同模块中的不同控制器。我该怎么做呢

测试模块控制器

<?php

namespace App\Modules\TestModule\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Response;
use App\Modules\TestModule\Http\Requests\TestModuleRequest;
use App\Modules\Admin\Http\Requests\AdminRequest;
use App\Modules\TestModule\Repositories\TestModuleRepository;
use App\Modules\TestModule\Services\TestModuleService;

class TestModuleController extends Controller
{
    /**
     * @var TestModuleRepository
     */
    protected $repo;

    /**
     * @var TestModuleService
     */
    protected $service;

    /**
     * TestModuleController constructor.
     *
     * @param TestModuleRepository $repo
     * @param TestModuleService $service
     */
    public function __construct(TestModuleRepository $repo, TestModuleService $service)
    {
        $this->repo = $repo;
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
        //echo "Here you are";
        //$data["data"] = "Here you are";

        //return view("welcome")->with($data);
        $working = "Its Working";
        $message = App::make("App\\Modules\\Admin\\Http\\Controllers\\AdminController")->create($working);

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */

}
尝试以下操作:

$message = Illuminate\Support\Facades\App::make("App\\Modules\\Admin\\Http\\Controllers\\AdminController")->create($working);

由于
App
在当前命名空间中不存在,您必须从定义它的位置调用它。

正在定义的类
App
在哪里?检查类App是否存在手动导入
使用Illumb\Support\Facades\App
使用
app()
帮助程序而不是
app
,即
app()->make(…)
或者您可以使用
\app
引用
应用程序
外观的根作用域别名(我猜这就是您想要使用的?)
$message = Illuminate\Support\Facades\App::make("App\\Modules\\Admin\\Http\\Controllers\\AdminController")->create($working);