
###前提・実現したいこと
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
1/* 以下、ファイル名です。 2/private/var/folders/th/2jk5hrjd261499nb2rrlm7t80000gn/T/fz3temp-2/2017_12_14_011712_create_posts_table.php 3*/ 4<?php 5 6use Illuminate\Support\Facades\Schema; 7use Illuminate\Database\Schema\Blueprint; 8use Illuminate\Database\Migrations\Migration; 9 10class CreatePostsTable extends Migration 11{ 12 /** 13 * Run the migrations. 14 * 15 * @return void 16 */ 17 public function up() 18 { 19 Schema::create('posts', function (Blueprint $table) { 20 $table->increments('id'); 21 $table->string('title'); 22 $table->test('body'); 23 $table->timestamps(); 24 }); 25 } 26 27 /** 28 * Reverse the migrations. 29 * 30 * @return void 31 */ 32 public function down() 33 { 34 Schema::dropIfExists('posts'); 35 } 36} 37
PHP
1/*以下、ファイル名です。 2database.php 3*/ 4<?php 5 6return [ 7 8 /* 9 |-------------------------------------------------------------------------- 10 | Default Database Connection Name 11 |-------------------------------------------------------------------------- 12 | 13 | Here you may specify which of the database connections below you wish 14 | to use as your default connection for all database work. Of course 15 | you may use many connections at once using the Database library. 16 | 17 */ 18 19 'default' => env('DB_CONNECTION', 'mysql'), 20 21 /* 22 |-------------------------------------------------------------------------- 23 | Database Connections 24 |-------------------------------------------------------------------------- 25 | 26 | Here are each of the database connections setup for your application. 27 | Of course, examples of configuring each database platform that is 28 | supported by Laravel is shown below to make development simple. 29 | 30 | 31 | All database work in Laravel is done through the PHP PDO facilities 32 | so make sure you have the driver for your particular database of 33 | choice installed on your machine before you begin development. 34 | 35 */ 36 37 'connections' => [ 38 'mysql' => [ 39 'driver' => 'mysql', 40 'host' => env('DB_HOST', 'localhost'), 41 'port' => env('DB_PORT', '3306'), 42 'database' => env('DB_DATABASE', '〇〇〇'), 43 'username' => env('DB_USERNAME', '△△△'), 44 'password' => env('DB_PASSWORD', '□□□'), 45 'unix_socket' => env('DB_SOCKET', '/private/tmp/mysql.sock'), 46 'charset' => 'utf8', 47 'collation' => 'utf8mb4_unicode_ci', 48 'prefix' => '', 49 'strict' => true, 50 'engine' => 'InnoDB', 51 ], 52 ], 53 54 /* 55 |-------------------------------------------------------------------------- 56 | Migration Repository Table 57 |-------------------------------------------------------------------------- 58 | 59 | This table keeps track of all the migrations that have already run for 60 | your application. Using this information, we can determine which of 61 | the migrations on disk haven't actually been run in the database. 62 | 63 */ 64 65 'migrations' => 'migrations', 66 67 /* 68 |-------------------------------------------------------------------------- 69 | Redis Databases 70 |-------------------------------------------------------------------------- 71 | 72 | Redis is an open source, fast, and advanced key-value store that also 73 | provides a richer set of commands than a typical key-value systems 74 | such as APC or Memcached. Laravel makes it easy to dig right in. 75 | 76 */ 77 78 'redis' => [ 79 80 'client' => 'predis', 81 82 'default' => [ 83 'host' => env('REDIS_HOST', '127.0.0.1'), 84 'password' => env('REDIS_PASSWORD', null), 85 'port' => env('REDIS_PORT', 6379), 86 'database' => 0, 87 ], 88 89 ], 90 91]; 92
/* .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)を使用



回答1件
あなたの回答
tips
プレビュー