3

I have installed Laravel 5 following this tutorial for installing Laravel 4 and have got a test site up and running on localhost:8888 using PHP's built in server as the tutorial explains at 5:05.

I would like to achieve a similar thing but serving the site through xampp with a root of http://localhost/laravel or something similar. My reason for this is that I have lots of other projects and databases set up in xampp and for now I would like to keep my development environment consistent.

I am running OSX Mavericks with PHP version 5.4.30, my editor is Coda 2. I have created a MySQL database in xampp and added the necessary details to my projects .env file but can't get the site showing.

UPDATE: Apparently all I had to do to serve the site was restart my servers on xampp and add /public to the end of my root url to see the site. however now I am faced with another problem. When I try to migrate the database...

php artisan migrate

I get no effect but the following message spat out...

exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(47): PDO->__construct('mysql:host=loca...', 'laravel-user', 'YdVNRS5fDbJMLh6...', Array)
#1 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(20): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=loca...', Array, Array)
#2 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/storage/framework/compiled.php(10598): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/storage/framework/compiled.php(10594): Illuminate\Database\Connectors\ConnectionFactory->createSingleConnection(Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/storage/framework/compiled.php(10512): Illuminate\Database\Connectors\ConnectionFactory->make(Array, 'mysql')
#5 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/storage/framework/compiled.php(10467): Illuminate\Database\DatabaseManager->makeConnection('mysql')
#6 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(167): Illuminate\Database\DatabaseManager->connection(NULL)
#7 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(135): Illuminate\Database\Migrations\DatabaseMigrationRepository->getConnection()
#8 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(371): Illuminate\Database\Migrations\DatabaseMigrationRepository->repositoryExists()
#9 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(101): Illuminate\Database\Migrations\Migrator->repositoryExists()
#10 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(54): Illuminate\Database\Console\Migrations\MigrateCommand->prepareDatabase()
#11 [internal function]: Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#12 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/storage/framework/compiled.php(922): call_user_func_array(Array, Array)
#13 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Console/Command.php(115): Illuminate\Container\Container->call(Array)
#14 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Console/Command.php(101): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/symfony/console/Symfony/Component/Console/Application.php(126): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(91): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /Applications/XAMPP/xamppfiles/htdocs/laravel-test/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 {main}

Does anyone know how to solve this issue?

Thanks

Dan

danbahrami
  • 1,014
  • 1
  • 9
  • 14
  • Are you looking for something like this? http://laravel.io/forum/11-25-2014-installing-laravel-in-a-subdirectory – Malte Köhrer Feb 23 '15 at 16:27
  • @MalteKöhrer thanks for the link, this was helpful. I had just been using the wrong path however I still cant get a database connection working. I have added more detail to my question. – danbahrami Feb 23 '15 at 16:42

1 Answers1

4

I found this answer elsewhere on Stack Overflow that fixed the issue for me. All I had to do was add the unix_socket line to the mysql section of my database.php file....

'mysql' => [
        'driver'    => 'mysql',
        'unix_socket'   => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'forge'),
        'username'  => env('DB_USERNAME', 'forge'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

And it works fine.

Community
  • 1
  • 1
danbahrami
  • 1,014
  • 1
  • 9
  • 14
  • Awesome ... .had similar problem on CentOS with XAMPP in the /opt directory. Adding line `'unix_socket' => '/opt/lampp/var/mysql/mysql.sock'` and things looked bright. Thanks! – Daniel Dec 23 '16 at 08:41