###前提・実現したいこと
Laravelでmigrateを試みたところ、エラーが発生しました。
そのため、テーブルの作成がLaravelを通して行えません。
現在、テストで仮想環境ではなく、レンタルサーバー内でそのまま開発を行っていて、サーバーにはソースコードの二番目の内容で接続をしています。
ちなみに、初期からデフォルトで入っていたであろうmigrateとusersという二つのテーブルは作成されていました。
+--------------------------------+
| Tables_in_ 〇〇〇
+--------------------------------+
| migrations |
| users |
+--------------------------------+
ちなみに、Laravelで使うテーブルをsqlで直接作成した場合、何か面倒なことはありますでしょうか?
###発生している問題・エラーメッセージ
In Connection.php line 664: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = 〇〇〇 and table_name = migrations) In Connector.php line 67: SQLSTATE[HY000] [2002] No such file or directory
###該当のソースコード
php
/* 以下、ファイル名です。 /private/var/folders/th/2jk5hrjd261499nb2rrlm7t80000gn/T/fz3temp-2/2017_12_14_011712_create_posts_table.php */ <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreatePostsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->test('body'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('posts'); } }
PHP
/*以下、ファイル名です。 database.php */ <?php 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' => env('DB_CONNECTION', 'mysql'), /* |-------------------------------------------------------------------------- | 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' => [ 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', '〇〇〇'), 'username' => env('DB_USERNAME', '△△△'), 'password' => env('DB_PASSWORD', '□□□'), 'unix_socket' => env('DB_SOCKET', '/private/tmp/mysql.sock'), 'charset' => 'utf8', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => 'InnoDB', ], ], /* |-------------------------------------------------------------------------- | 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 set of commands than a typical key-value systems | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ 'client' => 'predis', 'default' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => 0, ], ], ];
/* .env */ APP_NAME=Laravel APP_ENV=production APP_KEY= APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=https://〇〇 DB_CONNECTION=mysql DB_HOST=localhost DB_DATABASE=〇〇 DB_USERNAME=△△ DB_PASSWORD=□□ BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file SESSION_LIFETIME=120 QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER= MAIL_HOST= MAIL_PORT= MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION= PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET=
mysql> SHOW DATABASES; +----------------------+ | Database | +----------------------+ | information_schema | | 〇〇〇 | +----------------------+ 3 rows in set (0.00 sec)
Migration table created successfully. In Macroable.php line 96: Method test does not exist.
###試したこと
エラー個所を確認しましたが、如何せん、これが初めてのフレームワークなもので、理解が及びませんでした。
すでに,DBへのアクセスとクリエートテーブルは成功しているので、何が原因かわかりません。
初歩的な問題かもしれませんが、どうかよろしくお願いします。
###補足情報(言語/FW/ツール等のバージョンなど)
Larval5.5
レンタルサーバー(Bluehost)を使用
まだ回答がついていません
会員登録して回答してみよう