首页 > 解决方案 > 如何设置从 Git 存储库中提取的 Laravel/Lumen 项目(使用 composer)?

问题描述

我是 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我最终遇到了这个错误

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再次运行我得到了这些错误

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
}

所以基本上我不确定如何设置一个Laravel/Lumengit回购中提取的基本应用程序。

标签: phpmongodblaravelcomposer-phplumen

解决方案


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

推荐阅读