Laravel 8.x (LaraBBS) deployed to Heroku, based on MySQL implementation
1. Reference URL:https://www.shuijingwanwq.com/2021/12/29/5622/, Laravel 8.x is deployed to Heroku, based on PostgreSQL implementation. Therefore, some steps can be omitted.
2. In the local development environment, the Laravel native environment has been deployed. Open URL:http://larabbs.local/, the response 200. as shown in 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. as shown in Figure 2
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. Execute the command: heroku update to update to the latest version. as shown in Figure 3
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 file under the Laravel project, and tell Heroku what command to use to start the web server by configuring the file. Then you need to include the file into Git version control. as shown in Figure 4
web: vendor/bin/heroku-php-apache2 public/
6. Create a new application on Heroku using the heroku create command. Use Heroku Rename to make changes to the app name. as shown in Figure 5
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 application’s buildpack and tell Heroku that our application is written in PHP. as shown in Figure 6
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 the Artisan command that comes with Laravel to generate the App Key. The configuration is done based on the generated App Key. as shown in Figure 7
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 and deploy the code to Heroku. After the code is successfully pushed, you can use the command: heroku open to quickly open online applications. Response 500, because MySQL has not been configured. as shown in Figure 8
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, suitable for MySQL-driven applications. Tip: Please verify your account. as shown in Figure 9
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, verify credit card related information. As shown in Figure 10
12. Add ClearDB to your application and retrieve your database URL. The installation was successful. as shown in Figure 11
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 item for Heroku to determine whether the application is running on Heroku.
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 speaking, the application database is configured in config/database.php, so we need to define a help method for the database connection method of different environments for this configuration file, so that the database configuration information can be specified according to the different running environments of the application, we need to edit helpers.php file and write the following.
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:
Array
(
[scheme] => mysql
[host] => us-cdbr-east-05.cleardb.net
[user] => b034f6d0920fbc
[pass] => 1901ec77
[path] => /heroku_60d897c4592e150
[query] => reconnect=true
)
15. Use the GET_DB_CONFIG method just defined to configure the database. Replace the database configuration file with the following, config/database.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, and then perform database migration. Error: sqlstate[42000]: Syntax error or access Violation: 1071 specific key was too long; max key length is 767 bytes. as shown in Figure 12
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, modifyEngine=>null, forEngine=>innodb,.
'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. Execute the database migration again and report an error. sqlstate[42S01]: base table or view already EXISTS: 1050 tableusersALREADY EXISTS. as shown in Figure 13
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 Heroku ClearDB MySQL in Navicat for MySQL. Determine that the table already exists in the database: migrations, users. Delete manually. Figure 14
20. Execute the database migration again, but still report an error: sqlstate[42000]: Syntax error or access Violation: 1071 specific key was too long; max key length is 767 bytes. Description Edit config/database.php, modifyEngine=>null, forEngine=>innodb, . It doesn’t work.
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);. as shown in Figure 15
<?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. Execute the database migration and filling again, and report an error: class “faker\factory” not found. Description Error: sqlstate[42000]: Syntax error or access Violation: 1071 specific key was too long; max key length is 767 bytes. problem has been solved. as shown in Figure 16
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/, to solve the error: class “faker\factory” not found
24. Push to Heroku, report an error: Error: failed to install system packages! Your requirements could not be resolved to an installable set of packages.. as shown in Figure 17
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 is still reported when pushing.
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,PlatformPackage install fails with composer 2.2 lock file. This should be a bug in the Heroku platform itself. After more than 10 days, the retry was successful.
27. Delete all the tables in Navicat, and then copy the database of the local environment. Select all the tables in the database of the local environment, then Ctrl + C, then go to the online database, Ctrl + V. as shown in Figure 18
28. Open the URL:https://app-wangqiang-larabbs.herokuapp.com/. Deployment was successful. as shown in Figure 19











![再次推送,然后执行数据库迁移。报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes。](https://www.shuijingwanwq.com/wp-content/uploads/2022/01/12.png)
![再次执行数据库迁移,报错。SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists](https://www.shuijingwanwq.com/wp-content/uploads/2022/01/13.png)


![再次执行数据库迁移与填充,报错:Class "Faker\Factory" not found。说明 报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes。的问题已经得到解决。](https://www.shuijingwanwq.com/wp-content/uploads/2022/01/16.png)


