没有不值得去解决的问题,也没有不值得去学习的技术!

Deploy Laravel 8.x (LaraBBS) to Heroku with MySQL

Open the URL: https://app-wangqiang-larabbs.herokuapp.com/ . Deployment successful.

1. Reference URL: Laravel 8.x deployed to Heroku, based on PostgreSQL implementation. Therefore, some steps can be skipped.

2. In the local development environment, the deployment based on the Laravel native environment is already complete. Open the URL: http://larabbs.local/ , and it responds with a 200 status code. See Figure 1.

In the local development environment, the deployment based on the Laravel native environment is already complete. Open the URL: http://larabbs.local/ , and it responds with a 200 status code.
Figure 1

3. Verify your installation. To verify your CLI installation, use the heroku –version command. Current version: 7.53.0, latest version: 7.59.2. See Figure 2.

Verify your installation. To verify your CLI installation, use the heroku --version command. Current version: 7.53.0, latest version: 7.59.2.
Figure 2
Plaintext
PS E:\wwwroot\larabbs> heroku --version
 »   Warning: heroku update available from 7.53.0 to 7.59.2.
heroku/7.53.0 win32-x64 node-v12.21.0
PS E:\wwwroot\larabbs>

4. Run the command: heroku update to update to the latest version. See Figure 3.

Run the command: heroku update to update to the latest version.
Figure 3
Plaintext
PS E:\wwwroot\larabbs> heroku update
heroku: Updating CLI from 7.53.0 to 7.59.2... done
heroku: Updating CLI... done
PS E:\wwwroot\larabbs> heroku --version
heroku/7.59.2 win32-x64 node-v12.21.0
PS E:\wwwroot\larabbs>

5. To deploy the application to Heroku, we also need to create a new Procfile in the Laravel project. By configuring this file, we tell Heroku what command to use to start the web server. We then need to add this file to Git version control. See Figure 4.

Create a new Procfile in the Laravel project
Figure 4
Plaintext
web: vendor/bin/heroku-php-apache2 public/

6. Use the heroku create command to create a new app on Heroku. Use heroku rename to change the app name. See Figure 5.

Use the heroku create command to create a new app on Heroku. Use heroku rename to change the app name.
Figure 5
Plaintext
PS E:\wwwroot\larabbs> heroku create
Creating app... done, ⬢ damp-savannah-00068
https://damp-savannah-00068.herokuapp.com/ | https://git.heroku.com/damp-savannah-00068.git
PS E:\wwwroot\larabbs> heroku rename app-wangqiang-larabbs
Renaming damp-savannah-00068 to app-wangqiang-larabbs... done
https://app-wangqiang-larabbs.herokuapp.com/ | https://git.heroku.com/app-wangqiang-larabbs.git
 !    Don't forget to update git remotes for all other local checkouts of the app.
Git remote heroku updated
PS E:\wwwroot\larabbs>

7. Declare the app’s buildpack to tell Heroku that our application is written in PHP. See Figure 6.

Declare the app's buildpack to tell Heroku that our application is written in PHP.
Figure 6
Plaintext
PS E:\wwwroot\larabbs> heroku buildpacks:set heroku/php
Buildpack set. Next release on app-wangqiang-larabbs will use heroku/php.
Run git push heroku main to create a new release using this buildpack.
PS E:\wwwroot\larabbs>

8. Use Laravel’s built-in artisan command to generate an App Key. Complete the configuration based on the generated App Key. See Figure 7.

Use Laravel's built-in artisan command to generate an App Key. Complete the configuration based on the generated App Key.
Figure 7
Plaintext
PS E:\wwwroot\larabbs> php artisan key:generate --show
base64:t/Y/pkrV3vFkTmKgx1ZYnKGioiwZh+vfx/ZhoL+SPdE=
PS E:\wwwroot\larabbs> heroku config:set APP_KEY=base64:t/Y/pkrV3vFkTmKgx1ZYnKGioiwZh+vfx/ZhoL+SPdE=
Setting APP_KEY and restarting ⬢ app-wangqiang-larabbs... done, v3
APP_KEY: base64:t/Y/pkrV3vFkTmKgx1ZYnKGioiwZh+vfx/ZhoL+SPdE=
PS E:\wwwroot\larabbs>

9. Push the code and deploy it to Heroku. After the code is pushed successfully, you can use the command: heroku open to quickly open the online application. It responds with a 500 status code because MySQL is not yet configured. See Figure 8.

Push the code and deploy it to Heroku. After the code is pushed successfully, you can use the command: heroku open to quickly open the online application. It responds with a 500 status code because MySQL is not yet configured.
Figure 8
Plaintext
PS E:\wwwroot\larabbs> git push heroku main
Enumerating objects: 4436, done.
Counting objects: 100% (4436/4436), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4268/4268), done.
Writing objects: 100% (4436/4436), 6.06 MiB | 182.00 KiB/s, done.
Total 4436 (delta 721), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/php
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote:        - php (8.1.1)
remote:        - ext-gd (bundled with php)
remote:        - ext-mbstring (bundled with php)
remote:        - ext-pcntl (bundled with php)
remote:        - composer (2.2.3)
remote:        - apache (2.4.51)
remote:        - nginx (1.20.2)
remote: -----> Installing dependencies...
remote:        Composer version 2.2.3 2021-12-31 12:18:53
remote:        Installing dependencies from lock file
remote:        Verifying lock file contents can be installed on current platform.
remote:        Package operations: 84 installs, 0 updates, 0 removals
remote:          - Downloading doctrine/inflector (2.0.4)
remote:          - Downloading doctrine/lexer (1.2.1)
remote:          - Downloading symfony/polyfill-ctype (v1.23.0)
remote:          - Downloading webmozart/assert (1.10.0)
remote:          - Downloading dragonmantank/cron-expression (v3.1.0)
remote:          - Downloading symfony/polyfill-php80 (v1.23.1)
remote:          - Downloading symfony/polyfill-php73 (v1.23.0)
remote:          - Downloading symfony/polyfill-mbstring (v1.23.1)
remote:          - Downloading symfony/deprecation-contracts (v2.5.0)
remote:          - Downloading symfony/http-foundation (v5.4.2)
remote:          - Downloading psr/event-dispatcher (1.0.0)
remote:          - Downloading symfony/event-dispatcher-contracts (v2.5.0)
remote:          - Downloading symfony/event-dispatcher (v5.4.0)
remote:          - Downloading symfony/var-dumper (v5.4.2)
remote:          - Downloading psr/log (1.1.4)
remote:          - Downloading symfony/error-handler (v5.4.2)
remote:          - Downloading symfony/http-kernel (v5.4.2)
remote:          - Downloading voku/portable-ascii (1.5.6)
remote:          - Downloading phpoption/phpoption (1.8.1)
remote:          - Downloading graham-campbell/result-type (v1.0.4)
remote:          - Downloading vlucas/phpdotenv (v5.4.1)
remote:          - Downloading symfony/css-selector (v5.4.2)
remote:          - Downloading tijsverkoyen/css-to-inline-styles (2.2.4)
remote:          - Downloading symfony/routing (v5.4.0)
remote:          - Downloading symfony/process (v5.4.2)
remote:          - Downloading symfony/polyfill-php72 (v1.23.0)
remote:          - Downloading symfony/polyfill-intl-normalizer (v1.23.0)
remote:          - Downloading symfony/polyfill-intl-idn (v1.23.0)
remote:          - Downloading symfony/mime (v5.4.2)
remote:          - Downloading symfony/finder (v5.4.2)
remote:          - Downloading symfony/polyfill-intl-grapheme (v1.23.1)
remote:          - Downloading symfony/string (v5.4.2)
remote:          - Downloading psr/container (1.1.2)
remote:          - Downloading symfony/service-contracts (v2.5.0)
remote:          - Downloading symfony/console (v5.4.2)
remote:          - Downloading symfony/polyfill-iconv (v1.23.0)
remote:          - Downloading egulias/email-validator (2.1.25)
remote:          - Downloading swiftmailer/swiftmailer (v6.3.0)
remote:          - Downloading symfony/polyfill-php81 (v1.23.0)
remote:          - Downloading ramsey/collection (1.2.2)
remote:          - Downloading brick/math (0.9.3)
remote:          - Downloading ramsey/uuid (4.2.3)
remote:          - Downloading psr/simple-cache (1.0.1)
remote:          - Downloading opis/closure (3.6.2)
remote:          - Downloading symfony/translation-contracts (v2.5.0)
remote:          - Downloading symfony/translation (v5.4.2)
remote:          - Downloading nesbot/carbon (2.55.2)
remote:          - Downloading monolog/monolog (2.3.5)
remote:          - Downloading league/mime-type-detection (1.9.0)
remote:          - Downloading league/flysystem (1.1.9)
remote:          - Downloading nette/utils (v3.2.6)
remote:          - Downloading nette/schema (v1.2.2)
remote:          - Downloading dflydev/dot-access-data (v3.0.1)
remote:          - Downloading league/config (v1.1.1)
remote:          - Downloading league/commonmark (2.1.0)
remote:          - Downloading laravel/serializable-closure (v1.0.5)
remote:          - Downloading laravel/framework (v8.77.1)
remote:          - Downloading asm89/stack-cors (v2.0.3)
remote:          - Downloading fruitcake/laravel-cors (v2.0.4)
remote:          - Downloading psr/http-message (1.0.1)
remote:          - Downloading psr/http-client (1.0.1)
remote:          - Downloading ralouphie/getallheaders (3.0.3)
remote:          - Downloading psr/http-factory (1.0.1)
remote:          - Downloading guzzlehttp/psr7 (2.1.0)
remote:          - Downloading guzzlehttp/promises (1.5.1)
remote:          - Downloading guzzlehttp/guzzle (7.4.1)
remote:          - Downloading laravel/horizon (v5.7.17)
remote:          - Downloading laravel/sanctum (v2.13.0)
remote:          - Downloading nikic/php-parser (v4.13.2)
remote:          - Downloading psy/psysh (v0.10.12)
remote:          - Downloading laravel/tinker (v2.6.3)
remote:          - Downloading intervention/image (2.7.1)
remote:          - Downloading mews/captcha (3.2.6)
remote:          - Downloading ezyang/htmlpurifier (v4.13.0)
remote:          - Downloading mews/purifier (3.3.6)
remote:          - Downloading laravel-lang/lang (5.0.0)
remote:          - Downloading overtrue/laravel-lang (4.2.2)
remote:          - Downloading overtrue/pinyin (4.0.8)
remote:          - Downloading predis/predis (v1.1.9)
remote:          - Downloading spatie/laravel-permission (3.18.0)
remote:          - Downloading ckeditor/ckeditor (4.17.1)
remote:          - Downloading summerblue/administrator (8.0.0)
remote:          - Downloading summerblue/laravel-active (8.0.0)
remote:          - Downloading viacreative/sudo-su (1.1.0)
remote:          - Installing doctrine/inflector (2.0.4): Extracting archive
remote:          - Installing doctrine/lexer (1.2.1): Extracting archive
remote:          - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive
remote:          - Installing webmozart/assert (1.10.0): Extracting archive
remote:          - Installing dragonmantank/cron-expression (v3.1.0): Extracting archive
remote:          - Installing symfony/polyfill-php80 (v1.23.1): Extracting archive
remote:          - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive
remote:          - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive
remote:          - Installing symfony/deprecation-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/http-foundation (v5.4.2): Extracting archive
remote:          - Installing psr/event-dispatcher (1.0.0): Extracting archive
remote:          - Installing symfony/event-dispatcher-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/event-dispatcher (v5.4.0): Extracting archive
remote:          - Installing symfony/var-dumper (v5.4.2): Extracting archive
remote:          - Installing psr/log (1.1.4): Extracting archive
remote:          - Installing symfony/error-handler (v5.4.2): Extracting archive
remote:          - Installing symfony/http-kernel (v5.4.2): Extracting archive
remote:          - Installing voku/portable-ascii (1.5.6): Extracting archive
remote:          - Installing phpoption/phpoption (1.8.1): Extracting archive
remote:          - Installing graham-campbell/result-type (v1.0.4): Extracting archive
remote:          - Installing vlucas/phpdotenv (v5.4.1): Extracting archive
remote:          - Installing symfony/css-selector (v5.4.2): Extracting archive
remote:          - Installing tijsverkoyen/css-to-inline-styles (2.2.4): Extracting archive
remote:          - Installing symfony/routing (v5.4.0): Extracting archive
remote:          - Installing symfony/process (v5.4.2): Extracting archive
remote:          - Installing symfony/polyfill-php72 (v1.23.0): Extracting archive
remote:          - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive
remote:          - Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive
remote:          - Installing symfony/mime (v5.4.2): Extracting archive
remote:          - Installing symfony/finder (v5.4.2): Extracting archive
remote:          - Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive
remote:          - Installing symfony/string (v5.4.2): Extracting archive
remote:          - Installing psr/container (1.1.2): Extracting archive
remote:          - Installing symfony/service-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/console (v5.4.2): Extracting archive
remote:          - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive
remote:          - Installing egulias/email-validator (2.1.25): Extracting archive
remote:          - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
remote:          - Installing symfony/polyfill-php81 (v1.23.0): Extracting archive
remote:          - Installing ramsey/collection (1.2.2): Extracting archive
remote:          - Installing brick/math (0.9.3): Extracting archive
remote:          - Installing ramsey/uuid (4.2.3): Extracting archive
remote:          - Installing psr/simple-cache (1.0.1): Extracting archive
remote:          - Installing opis/closure (3.6.2): Extracting archive
remote:          - Installing symfony/translation-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/translation (v5.4.2): Extracting archive
remote:          - Installing nesbot/carbon (2.55.2): Extracting archive
remote:          - Installing monolog/monolog (2.3.5): Extracting archive
remote:          - Installing league/mime-type-detection (1.9.0): Extracting archive
remote:          - Installing league/flysystem (1.1.9): Extracting archive
remote:          - Installing nette/utils (v3.2.6): Extracting archive
remote:          - Installing nette/schema (v1.2.2): Extracting archive
remote:          - Installing dflydev/dot-access-data (v3.0.1): Extracting archive
remote:          - Installing league/config (v1.1.1): Extracting archive
remote:          - Installing league/commonmark (2.1.0): Extracting archive
remote:          - Installing laravel/serializable-closure (v1.0.5): Extracting archive
remote:          - Installing laravel/framework (v8.77.1): Extracting archive
remote:          - Installing asm89/stack-cors (v2.0.3): Extracting archive
remote:          - Installing fruitcake/laravel-cors (v2.0.4): Extracting archive
remote:          - Installing psr/http-message (1.0.1): Extracting archive
remote:          - Installing psr/http-client (1.0.1): Extracting archive
remote:          - Installing ralouphie/getallheaders (3.0.3): Extracting archive
remote:          - Installing psr/http-factory (1.0.1): Extracting archive
remote:          - Installing guzzlehttp/psr7 (2.1.0): Extracting archive
remote:          - Installing guzzlehttp/promises (1.5.1): Extracting archive
remote:          - Installing guzzlehttp/guzzle (7.4.1): Extracting archive
remote:          - Installing laravel/horizon (v5.7.17): Extracting archive
remote:          - Installing laravel/sanctum (v2.13.0): Extracting archive
remote:          - Installing nikic/php-parser (v4.13.2): Extracting archive
remote:          - Installing psy/psysh (v0.10.12): Extracting archive
remote:          - Installing laravel/tinker (v2.6.3): Extracting archive
remote:          - Installing intervention/image (2.7.1): Extracting archive
remote:          - Installing mews/captcha (3.2.6): Extracting archive
remote:          - Installing ezyang/htmlpurifier (v4.13.0): Extracting archive
remote:          - Installing mews/purifier (3.3.6): Extracting archive
remote:          - Installing laravel-lang/lang (5.0.0): Extracting archive
remote:          - Installing overtrue/laravel-lang (4.2.2): Extracting archive
remote:          - Installing overtrue/pinyin (4.0.8): Extracting archive
remote:          - Installing predis/predis (v1.1.9): Extracting archive
remote:          - Installing spatie/laravel-permission (3.18.0): Extracting archive
remote:          - Installing ckeditor/ckeditor (4.17.1): Extracting archive
remote:          - Installing summerblue/administrator (8.0.0): Extracting archive
remote:          - Installing summerblue/laravel-active (8.0.0): Extracting archive
remote:          - Installing viacreative/sudo-su (1.1.0): Extracting archive
remote:        Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
remote:        Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        Discovered Package: fruitcake/laravel-cors
remote:        Discovered Package: intervention/image
remote:        Discovered Package: laravel/horizon
remote:        Discovered Package: laravel/sanctum
remote:        Discovered Package: laravel/tinker
remote:        Discovered Package: mews/captcha
remote:        Discovered Package: mews/purifier
remote:        Discovered Package: nesbot/carbon
remote:        Discovered Package: overtrue/laravel-lang
remote:        Discovered Package: spatie/laravel-permission
remote:        Discovered Package: summerblue/administrator
remote:        Discovered Package: summerblue/laravel-active
remote:        Package manifest generated successfully.
remote:        54 packages you are using are looking for funding.
remote:        Use the `composer fund` command to find out more!
remote: -----> Preparing runtime environment...
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 34.2M
remote: -----> Launching...
remote:        Released v4
remote:        https://app-wangqiang-larabbs.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/app-wangqiang-larabbs.git
 * [new branch]      main -> main
PS E:\wwwroot\larabbs> heroku open
PS E:\wwwroot\larabbs>

10. Reference URL: https://devcenter.heroku.com/articles/cleardb . ClearDB is a powerful, high-speed cloud database-as-a-service for MySQL-driven applications. Note: Please verify your account. See Figure 9.

Reference URL: https://devcenter.heroku.com/articles/cleardb . ClearDB is a powerful, high-speed cloud database-as-a-service for MySQL-driven applications. Note: Please verify your account.
Figure 9
Plaintext
PS E:\wwwroot\larabbs> heroku addons:create cleardb:ignite
Creating cleardb:ignite on ⬢ app-wangqiang-larabbs... !
 !    Please verify your account to install this add-on plan (please enter a credit card) For more information, see
 !    https://devcenter.heroku.com/categories/billing Verify now at https://heroku.com/verify
PS E:\wwwroot\larabbs>

11. Open the URL: https://heroku.com/verify to verify your credit card information. See Figure 10.

Open the URL: https://heroku.com/verify to verify your credit card information.
Figure 10

12. Add ClearDB to your application and retrieve your database URL. Installation successful. See Figure 11.

Add ClearDB to your application and retrieve your database URL. Installation successful.
Figure 11
Plaintext
PS E:\wwwroot\larabbs> heroku addons:create cleardb:ignite
Creating cleardb:ignite on ⬢ app-wangqiang-larabbs... free
Created cleardb-curly-36388 as CLEARDB_DATABASE_URL
Use heroku addons:docs cleardb to view documentation
PS E:\wwwroot\larabbs> heroku config | grep CLEARDB_DATABASE_URL
grep : 无法将“grep”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确
,然后再试一次。
所在位置 行:1 字符: 17
+ heroku config | grep CLEARDB_DATABASE_URL
+                 ~~~~
    + CategoryInfo          : ObjectNotFound: (grep:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS E:\wwwroot\larabbs> heroku config
=== app-wangqiang-larabbs Config Vars
APP_KEY:              base64:t/Y/pkrV3vFkTmKgx1ZYnKGioiwZh+vfx/ZhoL+SPdE=
CLEARDB_DATABASE_URL: mysql://b034f6d0920fbc:1901ec77@us-cdbr-east-05.cleardb.net/heroku_60d897c4592e150?reconnect=true
PS E:\wwwroot\larabbs>

13. Add a new IS_IN_HEROKU configuration variable to Heroku to determine whether the application is running on Heroku.

Plaintext
PS E:\wwwroot\larabbs> heroku config:set IS_IN_HEROKU=true
Setting IS_IN_HEROKU and restarting ⬢ app-wangqiang-larabbs... done, v7
IS_IN_HEROKU: true
PS E:\wwwroot\larabbs> heroku config
=== app-wangqiang-larabbs Config Vars
APP_KEY:              base64:t/Y/pkrV3vFkTmKgx1ZYnKGioiwZh+vfx/ZhoL+SPdE=
CLEARDB_DATABASE_URL: mysql://b034f6d0920fbc:1901ec77@us-cdbr-east-05.cleardb.net/heroku_60d897c4592e150?reconnect=true
IS_IN_HEROKU:         true
PS E:\wwwroot\larabbs>

14. Generally, the application’s database is configured in config/database.php. Therefore, for this configuration file, we need to define a helper method for the database connection method in different environments, so as to specify the database configuration information based on the different running environments of the application. We need to edit the helpers.php file and write the following content.

PHP
function get_db_config()
{
    if (getenv('IS_IN_HEROKU')) {
        $url = parse_url(getenv("CLEARDB_DATABASE_URL"));

        return $db_config = [
            'connection' => 'mysql',
            'host' => $url["host"],
            'database'  => substr($url["path"], 1),
            'username'  => $url["user"],
            'password'  => $url["pass"],
        ];
    } else {
        return $db_config = [
            'connection' => env('DB_CONNECTION', 'mysql'),
            'host' => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
        ];
    }
}

Print $url:

Plaintext

Array
(
    [scheme] => mysql
    [host] => us-cdbr-east-05.cleardb.net
    [user] => b034f6d0920fbc
    [pass] => 1901ec77
    [path] => /heroku_60d897c4592e150
    [query] => reconnect=true
)


15. Use the newly defined get_db_config method to configure the database. Replace the database configuration file with the following content, config/database.php

PHP
<?php
 
use Illuminate\Support\Str;
 
$db_config = get_db_config();
 
return [
 
    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */
 
    'default' => $db_config['connection'],
 
    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */
 
    'connections' => [
 
        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],
 
        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => $db_config['host'],
            'port' => env('DB_PORT', '3306'),
            'database' => $db_config['database'],
            'username' => $db_config['username'],
            'password' => $db_config['password'],
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],
 
        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],
 
        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],
 
    ],
 
    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */
 
    'migrations' => 'migrations',
 
    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */
 
    'redis' => [
 
        'client' => env('REDIS_CLIENT', 'phpredis'),
 
        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'redis'),
            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
        ],
 
        'default' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB', '0'),
        ],
 
        'cache' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_CACHE_DB', '1'),
        ],
 
    ],
 
];
 

16. Push again, then run the database migration. Error: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes. See Figure 12.

Push again, then run the database migration. Error: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes.
Figure 12
Plaintext
PS E:\wwwroot\larabbs> git add -A
warning: LF will be replaced by CRLF in config/database.php.
The file will have its original line endings in your working directory
PS E:\wwwroot\larabbs> git commit -m "Updated database configuration"
[main 5513bdb] Updated database configuration
 1 file changed, 1 insertion(+)
PS E:\wwwroot\larabbs> git push heroku main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 374 bytes | 374.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/php
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote:        - php (8.1.1)
remote:        - ext-gd (bundled with php)
remote:        - ext-mbstring (bundled with php)
remote:        - ext-pcntl (bundled with php)
remote:        - composer (2.2.3)
remote:        - apache (2.4.51)
remote:        - nginx (1.20.2)
remote: -----> Installing dependencies...
remote:        Composer version 2.2.3 2021-12-31 12:18:53
remote:        Installing dependencies from lock file
remote:        Verifying lock file contents can be installed on current platform.
remote:        Package operations: 84 installs, 0 updates, 0 removals
remote:          - Installing doctrine/inflector (2.0.4): Extracting archive
remote:          - Installing doctrine/lexer (1.2.1): Extracting archive
remote:          - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive
remote:          - Installing webmozart/assert (1.10.0): Extracting archive
remote:          - Installing dragonmantank/cron-expression (v3.1.0): Extracting archive
remote:          - Installing symfony/polyfill-php80 (v1.23.1): Extracting archive
remote:          - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive
remote:          - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive
remote:          - Installing symfony/deprecation-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/http-foundation (v5.4.2): Extracting archive
remote:          - Installing psr/event-dispatcher (1.0.0): Extracting archive
remote:          - Installing symfony/event-dispatcher-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/event-dispatcher (v5.4.0): Extracting archive
remote:          - Installing symfony/var-dumper (v5.4.2): Extracting archive
remote:          - Installing psr/log (1.1.4): Extracting archive
remote:          - Installing symfony/error-handler (v5.4.2): Extracting archive
remote:          - Installing symfony/http-kernel (v5.4.2): Extracting archive
remote:          - Installing voku/portable-ascii (1.5.6): Extracting archive
remote:          - Installing phpoption/phpoption (1.8.1): Extracting archive
remote:          - Installing graham-campbell/result-type (v1.0.4): Extracting archive
remote:          - Installing vlucas/phpdotenv (v5.4.1): Extracting archive
remote:          - Installing symfony/css-selector (v5.4.2): Extracting archive
remote:          - Installing tijsverkoyen/css-to-inline-styles (2.2.4): Extracting archive
remote:          - Installing symfony/routing (v5.4.0): Extracting archive
remote:          - Installing symfony/process (v5.4.2): Extracting archive
remote:          - Installing symfony/polyfill-php72 (v1.23.0): Extracting archive
remote:          - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive
remote:          - Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive
remote:          - Installing symfony/mime (v5.4.2): Extracting archive
remote:          - Installing symfony/finder (v5.4.2): Extracting archive
remote:          - Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive
remote:          - Installing symfony/string (v5.4.2): Extracting archive
remote:          - Installing psr/container (1.1.2): Extracting archive
remote:          - Installing symfony/service-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/console (v5.4.2): Extracting archive
remote:          - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive
remote:          - Installing egulias/email-validator (2.1.25): Extracting archive
remote:          - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive
remote:          - Installing symfony/polyfill-php81 (v1.23.0): Extracting archive
remote:          - Installing ramsey/collection (1.2.2): Extracting archive
remote:          - Installing brick/math (0.9.3): Extracting archive
remote:          - Installing ramsey/uuid (4.2.3): Extracting archive
remote:          - Installing psr/simple-cache (1.0.1): Extracting archive
remote:          - Installing opis/closure (3.6.2): Extracting archive
remote:          - Installing symfony/translation-contracts (v2.5.0): Extracting archive
remote:          - Installing symfony/translation (v5.4.2): Extracting archive
remote:          - Installing nesbot/carbon (2.55.2): Extracting archive
remote:          - Installing monolog/monolog (2.3.5): Extracting archive
remote:          - Installing league/mime-type-detection (1.9.0): Extracting archive
remote:          - Installing league/flysystem (1.1.9): Extracting archive
remote:          - Installing nette/utils (v3.2.6): Extracting archive
remote:          - Installing nette/schema (v1.2.2): Extracting archive
remote:          - Installing dflydev/dot-access-data (v3.0.1): Extracting archive
remote:          - Installing league/config (v1.1.1): Extracting archive
remote:          - Installing league/commonmark (2.1.0): Extracting archive
remote:          - Installing laravel/serializable-closure (v1.0.5): Extracting archive
remote:          - Installing laravel/framework (v8.77.1): Extracting archive
remote:          - Installing asm89/stack-cors (v2.0.3): Extracting archive
remote:          - Installing fruitcake/laravel-cors (v2.0.4): Extracting archive
remote:          - Installing psr/http-message (1.0.1): Extracting archive
remote:          - Installing psr/http-client (1.0.1): Extracting archive
remote:          - Installing ralouphie/getallheaders (3.0.3): Extracting archive
remote:          - Installing psr/http-factory (1.0.1): Extracting archive
remote:          - Installing guzzlehttp/psr7 (2.1.0): Extracting archive
remote:          - Installing guzzlehttp/promises (1.5.1): Extracting archive
remote:          - Installing guzzlehttp/guzzle (7.4.1): Extracting archive
remote:          - Installing laravel/horizon (v5.7.17): Extracting archive
remote:          - Installing laravel/sanctum (v2.13.0): Extracting archive
remote:          - Installing nikic/php-parser (v4.13.2): Extracting archive
remote:          - Installing psy/psysh (v0.10.12): Extracting archive
remote:          - Installing laravel/tinker (v2.6.3): Extracting archive
remote:          - Installing intervention/image (2.7.1): Extracting archive
remote:          - Installing mews/captcha (3.2.6): Extracting archive
remote:          - Installing ezyang/htmlpurifier (v4.13.0): Extracting archive
remote:          - Installing mews/purifier (3.3.6): Extracting archive
remote:          - Installing laravel-lang/lang (5.0.0): Extracting archive
remote:          - Installing overtrue/laravel-lang (4.2.2): Extracting archive
remote:          - Installing overtrue/pinyin (4.0.8): Extracting archive
remote:          - Installing predis/predis (v1.1.9): Extracting archive
remote:          - Installing spatie/laravel-permission (3.18.0): Extracting archive
remote:          - Installing ckeditor/ckeditor (4.17.1): Extracting archive
remote:          - Installing summerblue/administrator (8.0.0): Extracting archive
remote:          - Installing summerblue/laravel-active (8.0.0): Extracting archive
remote:          - Installing viacreative/sudo-su (1.1.0): Extracting archive
remote:        Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
remote:        Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        Discovered Package: fruitcake/laravel-cors
remote:        Discovered Package: intervention/image
remote:        Discovered Package: laravel/horizon
remote:        Discovered Package: laravel/sanctum
remote:        Discovered Package: laravel/tinker
remote:        Discovered Package: mews/captcha
remote:        Discovered Package: mews/purifier
remote:        Discovered Package: nesbot/carbon
remote:        Discovered Package: overtrue/laravel-lang
remote:        Discovered Package: spatie/laravel-permission
remote:        Discovered Package: summerblue/administrator
remote:        Discovered Package: summerblue/laravel-active
remote:        Package manifest generated successfully.
remote:        54 packages you are using are looking for funding.
remote:        Use the `composer fund` command to find out more!
remote: -----> Preparing runtime environment...
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 34.2M
remote: -----> Launching...
remote:        Released v10
remote:        https://app-wangqiang-larabbs.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/app-wangqiang-larabbs.git
   0e4cf6e..5513bdb  main -> main
PS E:\wwwroot\larabbs> heroku run php artisan migrate
Running php artisan migrate on ⬢ app-wangqiang-larabbs... up, run.3041 (Free)
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

In Connection.php line 703:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQ
  L: alter table `users` add unique `users_email_unique`(`email`))


In Connection.php line 492:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes


PS E:\wwwroot\larabbs>

17. Edit config/database.php, change ‘engine’ => null, to ‘engine’ => ‘InnoDB’,.

PHP
        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => $db_config['host'],
            'port' => env('DB_PORT', '3306'),
            'database' => $db_config['database'],
            'username' => $db_config['username'],
            'password' => $db_config['password'],
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => 'InnoDB',
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

18. Run the database migration again, and an error occurs. SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists. See Figure 13.

Run the database migration again, and an error occurs. SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists
Figure 13
Plaintext
PS E:\wwwroot\larabbs> heroku run php artisan migrate
Running php artisan migrate on ⬢ app-wangqiang-larabbs... up, run.7215 (Free)
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migrating: 2014_10_12_000000_create_users_table

In Connection.php line 703:

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table `users` (`
  id` bigint unsigned not null auto_increment primary key, `name` varchar(255) not null, `email` varchar(255) not nul
  l, `email_verified_at` timestamp null, `password` varchar(255) not null, `remember_token` varchar(100) null, `creat
  ed_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engi
  ne = InnoDB)


In Connection.php line 492:

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists


PS E:\wwwroot\larabbs>

19. Connect to the Heroku ClearDB MySQL in Navicat for MySQL. Confirm that the tables: migrations and users already exist in the database. Manually delete them. See Figure 14.

Connect to the Heroku ClearDB MySQL in Navicat for MySQL. Confirm that the tables: migrations and users already exist in the database. Manually delete them.
Figure 14

20. Run the database migration again, and the same error still occurs: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes. This indicates that editing config/database.php to change ‘engine’ => null, to ‘engine’ => ‘InnoDB’, had no effect.

21. Reference URL: https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa . Edit app/Providers/AppServiceProvider.php. Add Schema::defaultStringLength(191);. See Figure 15.

Edit app/Providers/AppServiceProvider.php. Add Schema::defaultStringLength(191);.
Figure 15
PHP
<?php
 
namespace App\Providers;
 
use App\Observers\TopicObserver;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
 
class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        if (app()->isLocal()) {
            $this->app->register(\VIACreative\SudoSu\ServiceProvider::class);
        }
    }
 
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
        \App\Models\User::observe(\App\Observers\UserObserver::class);
        \App\Models\Reply::observe(\App\Observers\ReplyObserver::class);
        \App\Models\Topic::observe(\App\Observers\TopicObserver::class);
        \App\Models\Link::observe(\App\Observers\LinkObserver::class);
 
        \Illuminate\Pagination\Paginator::useBootstrap();
    }
}
 
 

22. Run the database migration and seeding again, and an error occurs: Class “Faker\Factory” not found. This indicates that the error: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes has been resolved. See Figure 16.

Run the database migration and seeding again, and an error occurs: Class "Faker\Factory" not found. This indicates that the error: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes has been resolved.
Figure 16
Plaintext
PS E:\wwwroot\larabbs> heroku run php artisan migrate:refresh --seed
Running php artisan migrate:refresh --seed on ⬢ app-wangqiang-larabbs... up, run.8649 (Free)
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migration table not found.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table (75.93ms)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table (68.13ms)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated:  2019_08_19_000000_create_failed_jobs_table (66.91ms)
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
Migrated:  2019_12_14_000001_create_personal_access_tokens_table (177.58ms)
Migrating: 2021_12_31_134920_add_avatar_and_introduction_to_users_table
Migrated:  2021_12_31_134920_add_avatar_and_introduction_to_users_table (57.13ms)
Migrating: 2021_12_31_155234_create_categories_table
Migrated:  2021_12_31_155234_create_categories_table (207.72ms)
Migrating: 2021_12_31_155935_seed_categories_data
Migrated:  2021_12_31_155935_seed_categories_data (16.28ms)
Migrating: 2021_12_31_161159_create_topics_table
Migrated:  2021_12_31_161159_create_topics_table (134.87ms)
Migrating: 2022_01_04_175444_create_replies_table
Migrated:  2022_01_04_175444_create_replies_table (254.93ms)
Migrating: 2022_01_05_101230_create_notifications_table
Migrated:  2022_01_05_101230_create_notifications_table (151.45ms)
Migrating: 2022_01_05_101456_add_notification_count_to_users_table
Migrated:  2022_01_05_101456_add_notification_count_to_users_table (53.74ms)
Migrating: 2022_01_05_114704_create_permission_tables
Migrated:  2022_01_05_114704_create_permission_tables (916.03ms)
Migrating: 2022_01_05_115758_seed_roles_and_permissions_data
Migrated:  2022_01_05_115758_seed_roles_and_permissions_data (1,113.49ms)
Migrating: 2022_01_05_164147_create_links_table
Migrated:  2022_01_05_164147_create_links_table (99.36ms)
Migrating: 2022_01_05_170327_add_references
Migrated:  2022_01_05_170327_add_references (456.77ms)
Migrating: 2022_01_06_094656_add_last_actived_at_to_users_table
Migrated:  2022_01_06_094656_add_last_actived_at_to_users_table (50.76ms)
Seeding: Database\Seeders\UsersTableSeeder

In DatabaseServiceProvider.php line 91:

  Class "Faker\Factory" not found


PS E:\wwwroot\larabbs>

23. Reference URL: https://www.shuijingwanwq.com/2021/12/31/5665/ , resolve the error: Class “Faker\Factory” not found

24. Push to Heroku, error: ERROR: Failed to install system packages! Your requirements could not be resolved to an installable set of packages. See Figure 17.

Push to Heroku, error: ERROR: Failed to install system packages! Your requirements could not be resolved to an installable set of packages.
Figure 17
Plaintext
PS E:\wwwroot\larabbs> git push heroku main
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 4 threads
Compressing objects: 100% (13/13), done.
Writing objects: 100% (13/13), 5.50 KiB | 468.00 KiB/s, done.
Total 13 (delta 11), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/php
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote:
remote:  !     ERROR: Failed to install system packages!
remote:  !
remote:  !     Your platform requirements (for runtimes and extensions) could
remote:  !     not be resolved to an installable set of dependencies, or a
remote:  !     platform package repository was unreachable.
remote:  !
remote:  !     This usually means that you (or packages you are using) depend
remote:  !     on a combination of PHP versions and/or extensions that are
remote:  !     currently not available on Heroku.
remote:  !
remote:  !     The following is the full output from the installation attempt:
remote:  !
remote:  !     > You are using Composer 1 which is deprecated. You should upgrade to Composer 2, see https://blog.packagist.com/deprecating-composer-1-support/
remote:  !     > Loading repositories with available runtimes and extensions
remote:  !     > Updating dependencies
remote:  !     > Your requirements could not be resolved to an installable set of packages.
remote:  !     >
remote:  !     >   Problem 1
remote:  !     >     - symfony/polyfill-ctype v1.24.0 requires php >=7.1 -> satisfiable by php[7.3.24, 7.3.25, 7.3.26, 7.3.27, 7.3.28, 7.3.29, 7.3.30, 7.3.31, 7.3.32, 7.3.33, 7.4.12, 7.4.13, 7.4.14, 7.4.15, 7.4.16, 7.4.19, 7.4.20, 7.4.21, 7.4.22, 7.4.23, 7.4.24, 7.4.25, 7.4.26, 7.4.27, 8.0.0, 8.0.0RC4, 8.0.1, 8.0.10, 8.0.11, 8.0.12, 8.0.13, 8.0.14, 8.0.2, 8.0.3, 8.0.6, 8.0.7, 8.0.8, 8.0.9, 8.1.0, 8.1.1].
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.24
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.25
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.26
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.27
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.28
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.29
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.30
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.31
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.32
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.3.33
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.12
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.13
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.14
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.15
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.16
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.19
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.20
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.21
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.22
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.23
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.24
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.25
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.26
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 7.4.27
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.0
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.0RC4
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.1
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.10
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.11
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.12
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.13
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.14
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.2
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.3
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.6
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.7
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.8
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.0.9
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.1.0
remote:  !     >     - don't install symfony/polyfill-ctype v1.24.0|don't install php 8.1.1
remote:  !     >     - Installation request for symfony/polyfill-ctype v1.24.0 -> satisfiable by symfony/polyfill-ctype[v1.24.0].
remote:  !     >
be installed. If dev requirements are blocking the update you have to resolve those problems.
remote:  !
remote:  !     For reference, the following runtimes are currently available:
remote:  !
remote:  !     PHP:  8.1.1, 8.1.0, 8.0.14, 8.0.13, 8.0.12, 8.0.11, 8.0.10,
remote:  !     8.0.9, 8.0.8, 8.0.7, 8.0.6, 8.0.3, 8.0.2, 8.0.1, 8.0.0,
remote:  !     8.0.0RC4, 7.4.27, 7.4.26, 7.4.25, 7.4.24, 7.4.23, 7.4.22,
remote:  !     7.4.21, 7.4.20, 7.4.19, 7.4.16, 7.4.15, 7.4.14, 7.4.13,
remote:  !     7.4.12, 7.3.33, 7.3.32, 7.3.31, 7.3.30, 7.3.29, 7.3.28,
remote:  !     7.3.27, 7.3.26, 7.3.25, 7.3.24
remote:  !
remote:  !     Please verify that all requirements for runtime versions in
remote:  !     'composer.lock' are compatible with the list above, and ensure
remote:  !     all required extensions are available for the desired runtimes.
remote:  !
remote:  !     When choosing a PHP runtimes and extensions, please also ensure
remote:  !     they are available on your app's stack (heroku-20), and select
remote:  !     a different stack if needed after consulting the article below.
remote:  !
remote:  !     For a list of supported runtimes & extensions on Heroku, please
remote:  !     refer to: https://devcenter.heroku.com/articles/php-support
remote:
remote:  !     Push rejected, failed to compile PHP app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to app-wangqiang-larabbs.
remote:
To https://git.heroku.com/app-wangqiang-larabbs.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/app-wangqiang-larabbs.git'

25. Update composer from 2.1.14 to 2.2.3. The same error still occurs when pushing.

Plaintext
PS E:\wwwroot\larabbs> composer self-update
Upgrading to version 2.2.3 (stable channel).

Use composer self-update --rollback to return to version 2.1.14
PS E:\wwwroot\larabbs> composer -v
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.2.3 2021-12-31 12:18:53

Usage:
  command [options] [arguments]


26. Reference URL: https://github.com/heroku/heroku-buildpack-php/issues/526, Platform package install fails with Composer 2.2 lock file. This should be a bug in the Heroku platform itself. A retry made more than 10 days later succeeded.

27. Delete all tables in Navicat, then copy the database from the local environment. Select all tables in the local environment database, press ctrl + c, then enter the online database and press ctrl + v. See Figure 18.

Delete all tables in Navicat, then copy the database from the local environment. Select all tables in the local environment database, press ctrl + c, then enter the online database and press ctrl + v.
Figure 18

28. Open the URL: https://app-wangqiang-larabbs.herokuapp.com/ . Deployment successful. See Figure 19.

Open the URL: https://app-wangqiang-larabbs.herokuapp.com/ . Deployment successful.
Figure 19

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系