1、参考网址:https://www.shuijingwanwq.com/2021/12/29/5622/ ,Laravel 8.x 部署至 Heroku,基于 PostgreSQL 实现。因此,一些步骤可省略。
2、在本地开发环境中,基于 Laravel 本机环境已经部署完毕。打开网址:http://larabbs.local/ ,响应 200。如图1
3、验证您的安装,要验证您的 CLI 安装,请使用 heroku –version 命令。当前版本:7.53.0,最新版本:7.59.2。如图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、执行命令:heroku update,以更新至最新版本。如图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、要将应用部署到 Heroku 上,我们还需要在 Laravel 项目下新建一个 Procfile 文件,通过配置该文件来告诉 Heroku 应当使用什么命令来启动 Web 服务器。接着还需要将该文件纳入到 Git 版本控制中。如图4
web: vendor/bin/heroku-php-apache2 public/
6、使用 heroku create 命令在 Heroku 上创建一个新应用。使用 heroku rename 来对应用名称进行更改。如图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 fanxiapp-wangqiang-larabbs Renaming damp-savannah-00068 to fanxiapp-wangqiang-larabbs... done https://fanxiapp-wangqiang-larabbs.herokuapp.com/ | https://git.heroku.com/fanxiapp-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、对应用的 buildpack 进行声明,告诉 Heroku 说我们的应用是用 PHP 写的。如图6
PS E:/wwwroot/larabbs> heroku buildpacks:set heroku/php Buildpack set. Next release on fanxiapp-wangqiang-larabbs will use heroku/php. Run git push heroku main to create a new release using this buildpack. PS E:/wwwroot/larabbs>
8、使用 Laravel 自带的 artisan 命令来生成 App Key。基于生成的 App Key 来完成配置。如图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 ⬢ fanxiapp-wangqiang-larabbs... done, v3 APP_KEY: base64:t/Y/pkrV3vFkTmKgx1ZYnKGioiwZh+vfx/ZhoL+SPdE= PS E:/wwwroot/larabbs>
9、将代码推送和部署到 Heroku 上。代码推送成功之后,可以使用命令:heroku open 来快速打开线上应用。响应 500,原因在于 MySQL 还未配置。如图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://fanxiapp-wangqiang-larabbs.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/fanxiapp-wangqiang-larabbs.git * [new branch] main -> main PS E:/wwwroot/larabbs> heroku open PS E:/wwwroot/larabbs>
10、参考网址:https://devcenter.heroku.com/articles/cleardb ,ClearDB 是一种强大、高速的云端数据库即服务,适用于 MySQL 驱动的应用程序。提示:请验证您的帐户。如图9
PS E:/wwwroot/larabbs> heroku addons:create cleardb:ignite Creating cleardb:ignite on ⬢ fanxiapp-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、打开网址:https://heroku.com/verify ,验证信用卡相关信息。如图10
12、将 ClearDB 添加到您的应用程序,检索您的数据库 URL。安装成功。如图11
PS E:/wwwroot/larabbs> heroku addons:create cleardb:ignite Creating cleardb:ignite on ⬢ fanxiapp-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 === fanxiapp-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、为 Heroku 新增一个 IS_IN_HEROKU 配置项来判断应用是否运行在 Heroku 上。
PS E:/wwwroot/larabbs> heroku config:set IS_IN_HEROKU=true Setting IS_IN_HEROKU and restarting ⬢ fanxiapp-wangqiang-larabbs... done, v7 IS_IN_HEROKU: true PS E:/wwwroot/larabbs> heroku config === fanxiapp-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、一般来说,应用的数据库都在 config/database.php 中进行配置,因此我们需要针对该配置文件,来为不同环境的数据库连接方式定义一个帮助方法,以便根据应用不同的运行环境来指定数据库配置信息,我们需要编辑 helpers.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', ''), ]; } }
打印 $url:
Array ( [scheme] => mysql [host] => us-cdbr-east-05.cleardb.net [user] => b034f6d0920fbc [pass] => 1901ec77 [path] => /heroku_60d897c4592e150 [query] => reconnect=true )
15、使用刚刚定义好的 get_db_config 方法对数据库进行配置。将数据库配置文件替换为以下内容,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、再次推送,然后执行数据库迁移。报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes。如图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://fanxiapp-wangqiang-larabbs.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/fanxiapp-wangqiang-larabbs.git 0e4cf6e..5513bdb main -> main PS E:/wwwroot/larabbs> heroku run php artisan migrate Running php artisan migrate on ⬢ fanxiapp-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、编辑 config/database.php,修改 ‘engine’ => null, 为 ‘engine’ => ‘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、再次执行数据库迁移,报错。SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists。如图13
PS E:/wwwroot/larabbs> heroku run php artisan migrate Running php artisan migrate on ⬢ fanxiapp-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、在 Navicat for MySQL 中连接 Heroku ClearDB MySQL。确定数据库中已经存在表:migrations、users。手动删除掉。如图14
20、再次执行数据库迁移,仍然报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes。说明 编辑 config/database.php,修改 ‘engine’ => null, 为 ‘engine’ => ‘InnoDB’, 。没有作用。
21、参考网址:https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa 。编辑 app/Providers/AppServiceProvider.php 。添加 Schema::defaultStringLength(191);。如图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、再次执行数据库迁移与填充,报错:Class “Faker/Factory” not found。说明 报错:SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes。的问题已经得到解决。如图16
PS E:/wwwroot/larabbs> heroku run php artisan migrate:refresh --seed Running php artisan migrate:refresh --seed on ⬢ fanxiapp-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、参考网址:https://www.shuijingwanwq.com/2021/12/31/5665/ ,解决 报错:Class “Faker/Factory” not found
24、推送至 Heroku,报错:ERROR: Failed to install system packages! Your requirements could not be resolved to an installable set of packages.。如图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 fanxiapp-wangqiang-larabbs. remote: To https://git.heroku.com/fanxiapp-wangqiang-larabbs.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/fanxiapp-wangqiang-larabbs.git'
25、更新 composer ,从 2.1.14 更新至 2.2.3。推送时仍然报同样的错误。
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、参考网址: https://github.com/heroku/heroku-buildpack-php/issues/526,Platform package install fails with Composer 2.2 lock file。这应该是 Heroku 平台本身的 Bug。后续间隔10余天后重试成功。
27、在 Navicat 中删除掉所有表,然后将本地环境的数据库复制过来。选择本地环境的数据库中的所有表,然后 ctrl + c,然后进入线上的数据库中,ctrl + v。如图18
28、打开网址:https://fanxiapp-wangqiang-larabbs.herokuapp.com/ 。部署成功。如图19
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250668.html