Search code examples
phplaravellaravel-artisansqlsrv

PHP Fatal error out of memory error while trying to migrate


I am having a problem with Laravel, when I try to run the command:

php artisan migrate

It always gives me back this error:

PHP Fatal error: Out of memory (allocated 1886912512) (tried to allocate 65488 bytes) in C:\xampp\htdocs\EServices\vendor\laravel\framework\src\Illuminate\Database\Grammar.php on line 35

I've already put this line in the Grammar.php folder it is referring to:

ini_set('memory_limit', '-1');

This problem starts happening when I change the default SQL lines to my sqlsrv (Database runs Microsoft SQL Server)

My .env file contains this:

APP_ENV=local
APP_KEY=base64:3Goo2ULThD6k3srhAUOmqFlevc+MzLBIYB85Ye1wYYY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=sqlsrv
DB_HOST=shareapp
DB_PORT=3306
DB_DATABASE=fms
DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

And then the code for the database.php is this:

'default' => env('DB_CONNECTION', 'sqlsrv'),

Then the definition of sqlsrv is this:

'sqlsrv' => [
        'driver' => 'sqlsrv',
        'host' => env('DB_HOST', 'shareapp'),
        'database' => env('DB_DATABASE', 'fmsStage'),
        'username' => env('DB_USERNAME', ''),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => 'dbo.',
    ],

I have absolutely no idea what to do and since I started trying to use Laravel I have had nothing but problems. This doesn't work then that doesn't work. It is all because of the database and these ODBC drivers that need to be installed, but I don't know how to fix all of this.


Solution

  • You can use php -d memory_limit=-1 artisan migrate to temporary bypass memory limits.