Dokku: PHP расширение mbstring отсутствует при развертывании Laravel приложения - PullRequest
0 голосов
/ 29 февраля 2020

Я все еще получаю эту ошибку ниже, говоря, что PHP расширение mbstring отсутствует при развертывании моего приложения Laravel (версия 6.17.1) с использованием Dokku (версия 0.18.3), хотя я следовал документации ( https://devcenter.heroku.com/articles/php-support#using -опциональные расширения ).

-----> Cleaning up...
-----> Building laravel-app from herokuish...
-----> Adding BUILD_ENV to build environment...
-----> Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
       Detected buildpacks: multi nodejs php
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-php.git
=====> Detected Framework: PHP
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote:        - php (7.4.3)
remote:        - ext-mbstring (bundled with php)
remote:        - apache (2.4.41)
remote:        - nginx (1.16.1)
remote: PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so (libonig.so.4: cannot open shared object file: No such file or directory), /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so (/app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
remote: PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so (libonig.so.4: cannot open shared object file: No such file or directory), /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so (/app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
remote: -----> Installing dependencies...
remote:        Composer version 1.9.3 2020-02-04 12:58:49
remote:        PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so (libonig.so.4: cannot open shared object file: No such file or directory), /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so (/app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
remote:        Loading composer repositories with package information
remote:        Installing dependencies from lock file
remote:        Your requirements could not be resolved to an installable set of packages.
remote:        
remote:          Problem 1
remote:            - The requested PHP extension ext-mbstring * is missing from your system. Install or enable PHP's mbstring extension.
remote:          Problem 2
remote:            - Installation request for laravel/framework v6.17.1 -> satisfiable by laravel/framework[v6.17.1].
remote:            - laravel/framework v6.17.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote:          Problem 3
remote:            - Installation request for league/commonmark 1.3.1 -> satisfiable by league/commonmark[1.3.1].
remote:            - league/commonmark 1.3.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote:          Problem 4
remote:            - Installation request for sentry/sentry 2.3.1 -> satisfiable by sentry/sentry[2.3.1].
remote:            - sentry/sentry 2.3.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote:          Problem 5
remote:            - laravel/framework v6.17.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote:            - sentry/sentry-laravel 1.7.0 requires illuminate/support 5.0 - 5.8 | ^6.0 | ^7.0 -> satisfiable by laravel/framework[v6.17.1].
remote:            - Installation request for sentry/sentry-laravel 1.7.0 -> satisfiable by sentry/sentry-laravel[1.7.0].
remote:        
remote:          To enable extensions, verify that they are enabled in your .ini files:
remote:            - /app/.heroku/php/etc/php/php.ini
remote:            - /app/.heroku/php/etc/php/conf.d/000-heroku.ini
remote:            - /app/.heroku/php/etc/php/conf.d/010-ext-zend_opcache.ini
remote:            - /app/.heroku/php/etc/php/conf.d/100-ext-mbstring.ini
remote:            - /tmp/buildpackKITei/conf/php/apm-nostart-overrides/apm-nostart-overrides.ini
remote:          You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
remote: 
remote:  !     ERROR: Dependency installation failed!
remote:  !     
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !     
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !     
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !     
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote: 

Что я пробовал:

  1. Обновление composer.json
{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2",
        "ext-mbstring": "*",
        "aws/aws-sdk-php": "^3.133",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "^6.2",
        "laravel/tinker": "^2.0",
        "sentry/sentry-laravel": "^1.6"
    },
    "require-dev": {
        "facade/ignition": "^1.4",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^8.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}
Запустите composer update git add и git commit и composer.json и composer.lock файлов перед развертыванием

Любая помощь приветствуется, спасибо!

1 Ответ

1 голос
/ 01 марта 2020

Проблема решена, вот шаги:

  1. Убедитесь, что ваше приложение использует эти 2 пакета сборки:
https://github.com/heroku/heroku-buildpack-apt
https://github.com/heroku/heroku-buildpack-php
Создайте новый файл Aptfile в каталоге root с содержимым, как показано ниже:
libonig-dev
libonig4
git add, git commit и разверните, теперь он должен работать

Ссылки:

  1. Ответ на ссылку и более подробно: https://github.com/gliderlabs/herokuish/issues/529#issuecomment - 592938477
  2. https://github.com/heroku/heroku-buildpack-apt
  3. https://github.com/heroku/heroku-buildpack-php
  4. Как установить / добавить buildpacks в докку: https://github.com/dokku/dokku/blob/master/docs/deployment/methods/buildpacks.md
  5. О Aptfile: https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-apt
...