【问题标题】:How to setup Laravel/Lumen project (using composer) pulled from a Git repo?如何设置从 Git 存储库中提取的 Laravel/Lumen 项目(使用 composer)?
【发布时间】:2019-06-28 17:27:21
【问题描述】:

我是 Laravel 的新手,我从 git repo 中提取了一个项目。 .gitIgnore 文件包含:

/vendor
/.idea
Homestead.json
Homestead.yaml
.env

我发现我的项目无法正常工作。这实际上是一个后端,使用流明和设置的路由,即使设置了也无法通过localhost:8080/myRouteName 访问

$router->group(['prefix' => 'myRouteName'], function () use ($router) {
    $router->post('/', ['middleware' => 'auth', 'uses' => 'MyController@store']);
});

所以我想我需要/vendor 文件夹,因为我想它是应用程序正常运行所必需的。我在项目目录中导航并运行命令:composer install,最终得到this error

PS C:\wamp64\www\myprojectname> composer install
  [Composer\Exception\NoSslException]
  The openssl extension is required for SSL/TLS protection but is not available. 
If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.
    install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

然后我打开我的 WAMP 目录并找不到 php.ini(php7.3.1,这是在我的 Windows 用户环境变量中设置的),因为我只看到 php-development.iniphp-production.ini

所以我最终得到了命令:

composer config -g -- disable-tls true

然后通过再次运行composer install,我得到了these errors

PS C:\wamp64\www\myprojectname> composer install
You are running Composer with SSL/TLS protection disabled.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for illuminate/encryption v5.6.15 -> satisfiable by illuminate/encryption[v5.6.15].
    - illuminate/encryption v5.6.15 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
  Problem 2
    - Installation request for illuminate/support v5.6.15 -> satisfiable by illuminate/support[v5.6.15].
    - illuminate/support v5.6.15 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
  Problem 3
    - Installation request for mongodb/mongodb 1.3.1 -> satisfiable by mongodb/mongodb[1.3.1].
    - mongodb/mongodb 1.3.1 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb is missing from your system.
  Problem 4
    - Installation request for phpunit/phpunit 7.0.3 -> satisfiable by phpunit/phpunit[7.0.3].
    - phpunit/phpunit 7.0.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
  Problem 5
    - illuminate/support v5.6.15 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/lumen-framework v5.6.3 requires illuminate/support 5.6.* -> satisfiable by illuminate/support[v5.6.15].
    - Installation request for laravel/lumen-framework v5.6.3 -> satisfiable by laravel/lumen-framework[v5.6.3].

尝试取消注释(在 php-development.iniphp-production.ini 中),例如:

extension=openssl
extension=mbstring

但这对错误没有帮助。 我的composer.json 文件如下所示:

{
    "name": "laravel/lumen",
    "description": "The Laravel Lumen Framework.",
    "keywords": ["framework", "laravel", "lumen"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.1.3",
        "google/apiclient": "^2.0",
        "jenssegers/mongodb": "^3.4",
        "laravel/lumen-framework": "5.6.*",
        "league/fractal": "^0.17.0",
        "vlucas/phpdotenv": "~2.2"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~7.0",
        "mockery/mockery": "~1.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/",
            "database/"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

所以基本上我不确定如何设置一个从git 存储库中提取的基本Laravel/Lumen 应用程序。

【问题讨论】:

  • php-development.ini 和 php-production.ini 文件在 WAMP 加载时没有被加载,这就是为什么取消注释这些文件中的任何一个行都不起作用的原因。将更改应用到this 帖子中概述的相应路径。然后重新启动 WAMP,看看会发生什么。您可能需要重新运行“composer config -g -- disable-tls true”。

标签: php mongodb laravel composer-php lumen


【解决方案1】:

Lumen 需要在您的 PHP ini 文件中启用以下 PHP 扩展。

OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension

(https://lumen.laravel.com/docs/5.7)

为了使用 WAMP 编辑正确的 php.ini 文件,您必须右键单击任务栏中的 wamp 图标,转到 PHP 并单击 php.ini。

在这个文件中你应该取消注释这两个扩展。

extension=openssl
extension=mbstring

【讨论】:

    猜你喜欢
    • 2022-12-15
    • 2020-11-10
    • 1970-01-01
    • 2015-01-19
    • 2016-07-07
    • 2018-01-02
    • 2023-03-16
    • 2011-12-11
    • 1970-01-01
    相关资源
    最近更新 更多