【问题标题】:Use laravel/framework instead of laravel/laravel in Zend Application在 Zend 应用程序中使用 laravel/framework 而不是 laravel/laravel
【发布时间】:2023-02-24 00:34:32
【问题描述】:

我有一个 Zend 应用程序,带有 composer.json 我使用以下命令安装了 laravel/framework:

docker-compose exec web-server composer require laravel/framework:8.*

我在 zend 应用程序中创建一个文件夹,将其命名为 spirit

"autoload": {
        "psr-4": {
            "App\\": "spirit/app/"
        }
    },
"require": {
    "php": "^7.4",
    "laravel/framework": "8.*"
}

要求是通过几个 URL 将用户重定向到这个 laravel 应用程序:

https://example.com :: 加载 zend 应用程序

https://example.com/auth :: 在 zend 中加载 laravel 应用程序。

zend 应用程序的 public/index.php,我检查 URL 是否用于身份验证,我加载 laravel 应用程序,加载它的 bootstrap/app.php

if (stripos($_SERVER['REQUEST_URI'], 'auth') !== FALSE) {

    $app = require_once __DIR__.'/../spirit/bootstrap/app.php';

    $kernel = $app->make(Kernel::class);

    $response = $kernel->handle(
        $request = Request::capture()
    )->send();

    $kernel->terminate($request, $response);
    exit();
}

我收到以下错误::

我们为什么这样做:

  1. 我们想使用同一个域。
  2. 我们想使用相同的 composer.json
  3. 我们有 Git Lab Ci-CD 管道,所以我们想使用相同的 git 流和 ci-cd 管道,并且有测试覆盖率、代码覆盖率、包安全检查,一切都在一个地方配置。

    有什么地方不对?

    我可以使用任何参考来使用 laravel 框架创建自己的 laravel 包吗?

【问题讨论】:

    标签: php laravel zend-framework


    【解决方案1】:

    我做了更改添加 :: require __DIR__.'/../vendor/autoload.php';

    如果 (stripos($_SERVER['REQUEST_URI'], 'auth') !== FALSE) {

    require __DIR__.'/../vendor/autoload.php';
    
    $app = require_once __DIR__.'/../spirit/bootstrap/app.php';
    
    $kernel = $app->make(Kernel::class);
    
    $response = $kernel->handle(
        $request = Request::capture()
    )->send();
    
    $kernel->terminate($request, $response);
    exit();
    

    }

    现在我收到以下错误:

    【讨论】:

    • 如果您有更多信息,请编辑您的问题。不要发布作为答案
    猜你喜欢
    • 2020-12-15
    • 2023-02-16
    • 1970-01-01
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 2022-12-16
    • 2019-01-20
    相关资源
    最近更新 更多