Laravel (Mandrill/Ajax) email sending on dev not production - php

I've spent all night trying different things and for the life of me I cannot get my site to send emails. I just deployed my first Laravel project to a live server (digitalocean), yet when on my vagrant dev machine I have no problems sending email, it isn't until I deploy that the problems began.
I know the 500 error is usually due to the CSRF tokens and passing them in your headers, but I am doing that and am still getting an error. I will post the code I assume would be relevant and if anyone can see what the hell I am doing wrong I will forever be in your debt.
MAIL: (Asterix for privacy)
return [
'driver' => 'smtp',
'host' => 'smtp.mandrillapp.com',
'port' => 587,
'from' => array('address' => '********#gmail.com', 'name' => 'Admin'),
'encryption' => 'tls',
'username' => '********#gmail.com',
'password' => '****************',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
HomeController #store method for email sending (works on dev)
public function store(ContactFormRequest $request)
{
Mail::send('emails.email', array(
'name' => $request->get('name'),
'email' => $request->get('email'),
'user_message' => $request->get('user_message')
), function($message)
{
$message->from('*********#gmail.com');
$message->to('********#gmail.com', 'Admin')->subject('Client Inquiry');
});
return Response::json(['response' => 200]);
}
AJAX (jQuery)
$('#submit-contact-form').click(function(e) {
e.preventDefault();
$('#submit-contact-form').val('Sending...');
var $form = $(this).parent('form');
var $action = $form.attr('action');
var $data = $form.serialize();
$.ajax({
url: $action,
method: 'POST',
headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') },
data: $data,
success: function(data) {
if (data.response == 200) {
$('#submit-contact-form').val('Thank You For Contacting Us!');
}
}
});
});
Routes.php: (contact form is on my homepage and posts to itself, works on dev)
Route::resource('/', 'HomeController', ['only' => ['index','store']]);
Finally Form: (discovered if posting to root, for the url you have to pass empty string with a space in it
{!! Form::open(array('url' => ' ', 'id' => 'contact-form')) !!}
blah blah blah
{!! Form::close() !!}
I am new to Laravel so i'm still learning, but this one has me stuck especially because it works on dev and not production.
Here is my error log:
[2015-05-14 06:29:01] production.ERROR: exception 'ErrorException' with message 'Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in /var/www/html/kraken/vendor/compiled.php on line 11268 and defined' in /var/www/html/kraken/vendor/compiled.php:11262
Stack trace:
#0 /var/www/html/kraken/vendor/compiled.php(11262): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Missing argumen...', '/var/www/html/k...', 11262, Array)
#1 /var/www/html/kraken/vendor/compiled.php(11268): Illuminate\Support\Manager->createDriver()
#2 /var/www/html/kraken/vendor/compiled.php(11258): Illuminate\Support\Manager->createDriver(NULL)
#3 /var/www/html/kraken/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php(92): Illuminate\Support\Manager->driver()
#4 /var/www/html/kraken/vendor/compiled.php(827): Illuminate\Mail\MailServiceProvider->Illuminate\Mail\{closure}(Object(Illuminate\Foundation\Application))
#5 /var/www/html/kraken/vendor/compiled.php(1027): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminate\Foundation\Application), Array)
#6 /var/www/html/kraken/vendor/compiled.php(980): Illuminate\Container\Container->build(Object(Closure), Array)
#7 /var/www/html/kraken/vendor/compiled.php(1493): Illuminate\Container\Container->make('swift.mailer', Array)
#8 /var/www/html/kraken/vendor/compiled.php(1213): Illuminate\Foundation\Application->make('swift.mailer')
#9 /var/www/html/kraken/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php(30): Illuminate\Container\Container->offsetGet('swift.mailer')
#10 /var/www/html/kraken/vendor/compiled.php(1027): Illuminate\Mail\MailServiceProvider->Illuminate\Mail\{closure}(Object(Illuminate\Foundation\Application), Array)
#11 /var/www/html/kraken/vendor/compiled.php(980): Illuminate\Container\Container->build(Object(Closure), Array)
#12 /var/www/html/kraken/vendor/compiled.php(1493): Illuminate\Container\Container->make('mailer', Array)
#13 /var/www/html/kraken/vendor/compiled.php(1213): Illuminate\Foundation\Application->make('mailer')
#14 /var/www/html/kraken/vendor/compiled.php(5276): Illuminate\Container\Container->offsetGet('mailer')
#15 /var/www/html/kraken/vendor/compiled.php(5262): Illuminate\Support\Facades\Facade::resolveFacadeInstance('mailer')
#16 /var/www/html/kraken/vendor/compiled.php(5296): Illuminate\Support\Facades\Facade::getFacadeRoot()
#17 /var/www/html/kraken/app/Http/Controllers/HomeController.php(28): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#18 /var/www/html/kraken/app/Http/Controllers/HomeController.php(28): Illuminate\Support\Facades\Mail::send('emails.email', Array, Object(Closure))
#19 [internal function]: App\Http\Controllers\HomeController->store(Object(App\Http\Requests\ContactFormRequest))
#20 /var/www/html/kraken/vendor/compiled.php(8287): call_user_func_array(Array, Array)
#21 /var/www/html/kraken/vendor/compiled.php(8354): Illuminate\Routing\Controller->callAction('store', Array)
#22 /var/www/html/kraken/vendor/compiled.php(8333): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\HomeController), Object(Illuminate\Routing\Route), 'store')
#23 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/kraken/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#25 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /var/www/html/kraken/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#27 /var/www/html/kraken/vendor/compiled.php(8334): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#28 /var/www/html/kraken/vendor/compiled.php(8320): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\HomeController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'store')
#29 /var/www/html/kraken/vendor/compiled.php(7317): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'store')
#30 /var/www/html/kraken/vendor/compiled.php(7288): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
#31 /var/www/html/kraken/vendor/compiled.php(6954): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#32 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/html/kraken/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#34 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /var/www/html/kraken/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#36 /var/www/html/kraken/vendor/compiled.php(6955): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#37 /var/www/html/kraken/vendor/compiled.php(6944): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#38 /var/www/html/kraken/vendor/compiled.php(6929): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#39 /var/www/html/kraken/vendor/compiled.php(1935): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#40 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#41 /var/www/html/kraken/vendor/compiled.php(8952): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 /var/www/html/kraken/vendor/compiled.php(2438): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /var/www/html/kraken/app/Http/Middleware/VerifyCsrfToken.php(17): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /var/www/html/kraken/vendor/compiled.php(8944): App\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#45 /var/www/html/kraken/vendor/compiled.php(12083): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /var/www/html/kraken/vendor/compiled.php(10785): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 /var/www/html/kraken/vendor/compiled.php(11789): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#50 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#51 /var/www/html/kraken/vendor/compiled.php(11738): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#52 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /var/www/html/kraken/vendor/compiled.php(2478): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#54 /var/www/html/kraken/vendor/compiled.php(8944): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#55 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#56 /var/www/html/kraken/vendor/compiled.php(8935): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#57 /var/www/html/kraken/vendor/compiled.php(1891): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#58 /var/www/html/kraken/vendor/compiled.php(1880): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#59 /var/www/html/kraken/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#60 {main}
I've already gone to Laracast and posted but didn't get any responses, if anyone can help me I would appreciate it so much, thanks guys.

Related

Endless event loop in laravel when artisan queue:work runned

When I run php artisan queue:work I get endless loop of published event which is App\Events\PikirPublished
I couldn't find where I made a mistake. But in my log I saw that it is because of Carbon.
[2017-08-09 14:43:20] local.ERROR: InvalidArgumentException: Unexpected data found.
Unexpected data found.
The separation symbol could not be found
Trailing data in /Users/akmyradov/code/pikirler-desktop/vendor/nesbot/carbon/src/Carbon/Carbon.php:582
Stack trace:
#0 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(709): Carbon\Carbon::createFromFormat('Y-m-d H:i:s', 'Sun, 06 Aug 201...')
#1 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(122): Illuminate\Database\Eloquent\Model->asDateTime('Sun, 06 Aug 201...')
#2 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(84): Illuminate\Database\Eloquent\Model->addDateAttributesToArray(Array)
#3 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(900): Illuminate\Database\Eloquent\Model->attributesToArray()
#4 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(929): Illuminate\Database\Eloquent\Model->toArray()
#5 [internal function]: Illuminate\Database\Eloquent\Model->jsonSerialize()
#6 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php(95): json_encode(Array)
#7 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(48): Illuminate\Broadcasting\Broadcasters\RedisBroadcaster->broadcast(Array, 'App\\Events\\Piki...', Array)
#8 [internal function]: Illuminate\Broadcasting\BroadcastEvent->handle(Object(Illuminate\Broadcasting\Broadcasters\RedisBroadcaster))
#9 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#10 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#11 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#12 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#13 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#14 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#15 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#16 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(42): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Broadcasting\BroadcastEvent), false)
#18 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(69): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#19 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(317): Illuminate\Queue\Jobs\Job->fire()
#20 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(267): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#21 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(113): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#22 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))
#23 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(84): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')
#24 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#25 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#26 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#27 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#28 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#29 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#30 /Users/akmyradov/code/pikirler-desktop/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#31 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#32 /Users/akmyradov/code/pikirler-desktop/vendor/symfony/console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /Users/akmyradov/code/pikirler-desktop/vendor/symfony/console/Application.php(228): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /Users/akmyradov/code/pikirler-desktop/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /Users/akmyradov/code/pikirler-desktop/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 /Users/akmyradov/code/pikirler-desktop/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#37 {main}

Laravel Passport unsupported_grant_type

I have been stuck on Laravel Passport issue for 4 days now.
Following is my code base to verify login credentials and thus verify user login (token based)
I have followed all the steps for Passport integration.
API I call (From Postman):
http://localhost/oauth/token/?email=admin#test.com&password=Abcd#123&grant_type=password&client_id=10&client_secret=xqVaBzFyC2fVDwyd6Pk7nsy2o45GfYAgUKeR2OjK&scope=*
i.e.
email:admin#test.com
password:Abcd#123
grant_type:password
client_id:3
client_secret:xqVaBsdfsdfsf42fso45GfYAgUKeR2OjK
scope:*
config/auth.php
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
But I am getting the error :
{
"error": "unsupported_grant_type",
"message": "The authorization grant type is not supported by the authorization server.",
"hint": "Check the `grant_type` parameter"
}
Error I received
[2017-03-08 12:12:10] local.ERROR: League\OAuth2\Server\Exception\OAuthServerException: The authorization grant type is not supported by the authorization server. in /var/www/html/test/testProj/Proj_Latest/vendor/league/oauth2-server/src/Exception/OAuthServerException.php:65
Stack trace:
#0 /var/www/html/test/testProj/Proj_Latest/vendor/league/oauth2-server/src/AuthorizationServer.php(204): League\OAuth2\Server\Exception\OAuthServerException::unsupportedGrantType()
#1 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/passport/src/Http/Controllers/AccessTokenController.php(63): League\OAuth2\Server\AuthorizationServer->respondToAccessTokenRequest(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response))
#2 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/passport/src/Http/Controllers/HandlesOAuthErrors.php(25): Laravel\Passport\Http\Controllers\AccessTokenController->Laravel\Passport\Http\Controllers\{closure}()
#3 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/passport/src/Http/Controllers/AccessTokenController.php(64): Laravel\Passport\Http\Controllers\AccessTokenController->withErrorHandling(Object(Closure))
#4 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): Laravel\Passport\Http\Controllers\AccessTokenController->issueToken(Object(Zend\Diactoros\ServerRequest))
#5 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Laravel\Passport\Http\Controllers\AccessTokenController), 'issueToken')
#6 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(160): Illuminate\Routing\Route->runController()
#7 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(559): Illuminate\Routing\Route->run()
#8 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#9 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#10 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#13 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(561): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#14 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(520): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#15 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(498): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#16 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(174): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#17 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#18 /var/www/html/test/testProj/Proj_Latest/app/Http/Middleware/ResponseLogger.php(22): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#19 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\ResponseLogger->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 /var/www/html/test/testProj/Proj_Latest/app/Http/Middleware/RequestLogger.php(45): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\RequestLogger->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/test/testProj/Proj_Latest/app/Http/Middleware/Cors.php(18): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#25 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\Cors->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#30 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#46 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#47 /var/www/html/test/testProj/Proj_Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#48 /var/www/html/test/testProj/Proj_Latest/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#49 {main}
Now since this did not work, I tried the method :
Auth::attempt(array('email' => 'admin#test.com', 'password' => 'Abcd#123'))
But this time I received :
[2017-03-08 12:00:00] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Auth\RequestGuard::attempt() in /var/www/html/..../vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php:294
Nothing seems to be working in Laravel 5.4
First of all, make sure that the grant client is a 'password client', creaded similiarly as with the command:
php artisan passport:client --password
This means that the 'password_client' column in the database has the value '1' next to the corresponding client.
I also struggled a lot with the default user clients created from the user interface, and it doesn't work with those.

Why is the Dependency injection not working?

I am having a problem in dependency injection, the error I get is:
local.ERROR: exception 'ErrorException' with message 'Argument 1 passed to App\Http\Controllers\APIsController::get_JWT_token() must be an instance of GenTux\Jwt\JwtToken, integer given, called in C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Services\Access\Traits\RegistersUsers.php on line 82 and defined' in C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Http\Controllers\APIsController.php:163
Although I am including JwtToken in the APIsController as:
use GenTux\Jwt\GetsJwtToken;
use GenTux\Jwt\JwtToken;
use GetsJwtToken;
// $jwt is not injected
public function get_JWT_token(JwtToken $jwt, $user_id = null)
{
if ($user_id == null) {
$payload = [
'exp' => time() + (60 * 60 * 24 * 30),
'user_id' => Auth::user()->getKey(),
'product_name' => env('PRODUCT_NAME')
];
} else {
$payload = [
'exp' => time() + (60 * 60 * 24 * 360),
'user_id' => $user_id,
'product_name' => env('PRODUCT_NAME')
];
}
$token = 'Bearer ' . $jwt->createToken($payload); // new instance of JwtToken
return $token;
}
I do call the method as:
$apis = new APIsController();
$JWT_token = $apis->get_JWT_token($user->id);
I also register the package as:
[config\app.php]:
in providers:
GenTux\Jwt\Support\LaravelServiceProvider::class,
So, why did the dependency injection not work?
Here is the full Stack trace:
#0 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Http\Controllers\APIsController.php(163): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(4096, 'Argument 1 pass...', 'C:\\Bitnami\\wapp...', 163, Array)
#1 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Services\Access\Traits\RegistersUsers.php(82): App\Http\Controllers\APIsController->get_JWT_token(Object(App\Models\Access\User\User))
#2 [internal function]: App\Http\Controllers\Frontend\Auth\AuthController->register(Object(App\Http\Requests\Frontend\Auth\RegisterRequest))
#3 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(80): call_user_func_array(Array, Array)
#4 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('register', Array)
#5 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\Frontend\Auth\AuthController), Object(Illuminate\Routing\Route), 'register')
#6 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#7 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#8 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#9 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#10 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#11 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\Frontend\Auth\AuthController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'register')
#12 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'register')
#13 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Route.php(140): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#14 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Router.php(724): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#15 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#16 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#17 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(48): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 [internal function]: Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), '60', '1')
#19 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#20 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#22 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Http\Middleware\RedirectIfAuthenticated.php(28): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#23 [internal function]: App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#25 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#27 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Http\Middleware\LocaleMiddleware.php(48): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 [internal function]: App\Http\Middleware\LocaleMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#30 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#32 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\app\Http\Middleware\FilterIfTurbolinks.php(18): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 [internal function]: App\Http\Middleware\FilterIfTurbolinks->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#35 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#37 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#38 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#39 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#40 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#42 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#45 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#46 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#47 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#48 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#50 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#52 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#53 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#54 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#55 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#56 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#57 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#58 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#59 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#60 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#61 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#62 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#63 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#64 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#65 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\barryvdh\laravel-debugbar\src\Middleware\Debugbar.php(51): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#66 [internal function]: Barryvdh\Debugbar\Middleware\Debugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#67 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#68 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#69 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#70 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#71 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#72 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(136): call_user_func_array(Array, Array)
#73 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#74 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#75 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#76 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#77 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#78 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#79 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\public\index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#80 C:\Bitnami\wappstack-5.6.29-0\apache2\htdocs\testproject\business-web\server.php(21): require_once('C:\\Bitnami\\wapp...')
#81 {main}
The error is
Argument 1 passed to App\Http\Controllers\APIsController::get_JWT_token() must be an instance of GenTux\Jwt\JwtToken, integer given
In here
$JWT_token = $apis->get_JWT_token($user->id);
You are indeed giving an integer as the 1st argument, which is $user->id
Instead you should provide
GenTux\Jwt\JwtToken
instance.
-- Edit after #user7409342's input--
You could do this
public function get_JWT_token($user_id = null)
{
$jwt = app(JwtToken::class); // Resolve JwtToken using app()
if ($user_id == null) {
$payload = [
'exp' => time() + (60 * 60 * 24 * 30),
'user_id' => Auth::user()->getKey(),
'product_name' => env('PRODUCT_NAME')
];
} else {
$payload = [
'exp' => time() + (60 * 60 * 24 * 360),
'user_id' => $user_id,
'product_name' => env('PRODUCT_NAME')
];
}
$token = 'Bearer ' . $jwt->createToken($payload); // new instance of JwtToken
return $token;
}
$JWT_token = $apis->get_JWT_token($user->id);
Here you are passing first argument as user_id and get_JWT_token function first argument is the JwtToken object that's making the issue so change the definition of function like below.
public function get_JWT_token(JwtToken $jwt, $user_id = null)
{
...// your code
}

Intervention cannot write image to the path in Laravel

I am trying to execute following code
if(Input::hasFile('image_small')){
$image1 = Input::file('image_small');
$path = public_path('images/album/small/'.$albumcode);
$xx = File::delete($album->album_art);
Image::make($image1->getRealPath())->resize(256,256)->save($path.'/'.$filename);
dd($xx.' : '.$album->album_art);
}
But I am getting following error
Can't write image data to path
(/home/vqujcxca/madmuzik/public/images/album/small/MAD_ALBUM-2016-0004/akkual_sm.jpg)
Following is my latest stack trace
[2016-08-05 12:09:40] production.ERROR: exception 'Intervention\Image\Exception\NotWritableException' with message 'Can't write image data to path (/home/vqujcxca/madmuzik/public/images/album/small/MAD_ALBUM-2016-0004/akkual_sm.jpg)' in /home/vqujcxca/madmuzik/vendor/intervention/image/src/Intervention/Image/Image.php:143
Stack trace:
#0 /home/vqujcxca/madmuzik/app/Http/Controllers/AdminController.php(625): Intervention\Image\Image->save('/home/vqujcxca/...')
#1 [internal function]: App\Http\Controllers\AdminController->postUpdatesmallimage(Object(Illuminate\Http\Request))
#2 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(80): call_user_func_array(Array, Array)
#3 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('postUpdatesmall...', Array)
#4 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\AdminController), Object(Illuminate\Routing\Route), 'postUpdatesmall...')
#5 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#6 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#7 /home/vqujcxca/madmuzik/app/Http/Middleware/Authenticate.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#8 [internal function]: App\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#9 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#10 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#12 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#13 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#14 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#15 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\AdminController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'postUpdatesmall...')
#16 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'postUpdatesmall...')
#17 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Route.php(140): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#18 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Router.php(724): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#19 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#20 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#21 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#24 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#26 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#29 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#30 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#31 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#32 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#34 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#36 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#39 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#40 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#41 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#42 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#44 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#46 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#47 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#48 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#49 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#50 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#51 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#52 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#53 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#54 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#56 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#57 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#58 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#59 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#60 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#61 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#62 /home/vqujcxca/madmuzik/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#63 /home/vqujcxca/public_html/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#64 {main}
You have to also make the $albumcode (/MAD_ALBUM-2016-0004) folder before saving the images
OR may
change this:
public_path('images/album/small/'.$albumcode);
To this:
$path = 'images/album/small/'.$albumcode;

PHPUnit testing FAILS ONLY when visiting the root page( visit('/') ) in Laravel 5

I run Laravel applic ation in docker container dockervel and
the test
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware ;
use Illuminate\Foundation\Testing\DatabaseMigrations ;
use Illuminate\Foundation\Testing\DatabaseTransactions ;
use App\User1;
class MyTest extends TestCase
{
public function testExample()
{
$this->assertTrue(true);
}
public function providerAllUrisWithResponseCode()
{
return [
['/', 200],
['/thank', 200],
['/non-existing', 404],
];
}
public function testDisplayThankYou($value='')
{
$this->visit('/thankyou')
->see('THank you!');
}
public function testNewUserRegistration()
{
$this->visit('/')
->type('Taylor', 'name')
->type('taylor#talor.com', 'email')
->press('Register')
->seePageIs('/thankyou');
}
public function testPageControllerGet()
{
$this->call('GET', '/');
}
public function testPageControllerGettoThankYou()
{
$this->call('GET', 'thankyou');
}
public function testUser1ControllerPost()
{
$response= $this->call('POST', '/');
}
}
IT FAILS ONLY on method testNewUserRegistration when $this->visit('/') it says:
There was 1 failure:
1) MyTest::testDisplayWelcome
A request to [http://localhost] failed. Received status code [500].
Caused by
exception 'PDOException' with message 'SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql' (2)' in ..vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:55
Note:Can into database thru my app.
laravel.log:
[2016-06-27 09:02:53] testing.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql' (2)' in ../vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:55
Stack trace:
#0 ../vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(55): PDO->__construct('mysql:host=mysq...', 'homestead', 'secret', Array)
#1 ../vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=mysq...', Array, Array)
#2 ../vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(61): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#4 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(908): call_user_func(Object(Closure))
#5 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(776): Illuminate\Database\Connection->getPdo()
#6 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(661): Illuminate\Database\Connection->reconnectIfMissingConnection()
#7 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(342): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure))
#8 ../vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1583): Illuminate\Database\Connection->select('select * from `...', Array, true)
#9 ../vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1569): Illuminate\Database\Query\Builder->runSelect()
#10 ../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(624): Illuminate\Database\Query\Builder->get(Array)
#11 ../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(316): Illuminate\Database\Eloquent\Builder->getModels(Array)
#12 ../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(649): Illuminate\Database\Eloquent\Builder->get(Array)
#13 ../app/Http/Controllers/PageController.php(14): Illuminate\Database\Eloquent\Model::all()
#14 [internal function]: App\Http\Controllers\PageController->home()
#15 ../vendor/laravel/framework/src/Illuminate/Routing/Controller.php(80): call_user_func_array(Array, Array)
#16 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('home', Array)
#17 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\PageController), Object(Illuminate\Routing\Route), 'home')
#18 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#19 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#22 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#23 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\PageController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'home')
#24 ../vendor/laravel/framework/src/Illuminate/Routing/Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'home')
#25 ../vendor/laravel/framework/src/Illuminate/Routing/Route.php(140): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#26 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(724): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#27 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#29 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#32 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#34 ../vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#35 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#37 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#39 ../vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#42 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#44 ../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#47 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#49 ../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#51 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#52 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#53 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#54 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#56 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#57 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#58 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#59 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#60 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#61 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#62 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#63 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#64 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#65 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#66 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#67 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#68 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#69 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#70 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#71 ../vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(515): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#72 ../vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php(78): Illuminate\Foundation\Testing\TestCase->call('GET', 'http://localhos...', Array, Array, Array)
#73 ../vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php(61): Illuminate\Foundation\Testing\TestCase->makeRequest('GET', '/')
#74 ../tests/MyTest.php(38): Illuminate\Foundation\Testing\TestCase->visit('/')
#75 [internal function]: MyTest->testNewUserRegistration()
#76 ../vendor/phpunit/phpunit/src/Framework/TestCase.php(909): ReflectionMethod->invokeArgs(Object(MyTest), Array)
#77 ../vendor/phpunit/phpunit/src/Framework/TestCase.php(768): PHPUnit_Framework_TestCase->runTest()
#78 ../vendor/phpunit/phpunit/src/Framework/TestResult.php(612): PHPUnit_Framework_TestCase->runBare()
#79 ../vendor/phpunit/phpunit/src/Framework/TestCase.php(724): PHPUnit_Framework_TestResult->run(Object(MyTest))
#80 ../vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#81 ../vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#82 ../vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#83 ../vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#84 ../vendor/phpunit/phpunit/src/TextUI/Command.php(100): PHPUnit_TextUI_Command->run(Array, true)
#85 ../vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#86 {main}
[2016-06-27 09:03:05] testing.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [2005] Unknown MySQL server host 'mysql' (2)' in ../vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:55
Stack trace:
#0 ../vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(55): PDO->__construct('mysql:host=mysq...', 'homestead', 'secret', Array)
#1 ../vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=mysq...', Array, Array)
#2 ../vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(61): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#4 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(908): call_user_func(Object(Closure))
#5 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(776): Illuminate\Database\Connection->getPdo()
#6 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(661): Illuminate\Database\Connection->reconnectIfMissingConnection()
#7 ../vendor/laravel/framework/src/Illuminate/Database/Connection.php(342): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure))
#8 ../vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1583): Illuminate\Database\Connection->select('select * from `...', Array, true)
#9 ../vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1569): Illuminate\Database\Query\Builder->runSelect()
#10 ../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(624): Illuminate\Database\Query\Builder->get(Array)
#11 ../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(316): Illuminate\Database\Eloquent\Builder->getModels(Array)
#12 ../vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(649): Illuminate\Database\Eloquent\Builder->get(Array)
#13 ../app/Http/Controllers/PageController.php(14): Illuminate\Database\Eloquent\Model::all()
#14 [internal function]: App\Http\Controllers\PageController->home()
#15 ../vendor/laravel/framework/src/Illuminate/Routing/Controller.php(80): call_user_func_array(Array, Array)
#16 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(146): Illuminate\Routing\Controller->callAction('home', Array)
#17 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(94): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\PageController), Object(Illuminate\Routing\Route), 'home')
#18 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#19 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#20 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#22 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(96): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#23 ../vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(54): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\PageController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'home')
#24 ../vendor/laravel/framework/src/Illuminate/Routing/Route.php(174): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'home')
#25 ../vendor/laravel/framework/src/Illuminate/Routing/Route.php(140): Illuminate\Routing\Route->runController(Object(Illuminate\Http\Request))
#26 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(724): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#27 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#28 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#29 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#32 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#34 ../vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#35 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#37 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#39 ../vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#42 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#44 ../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#47 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#49 ../vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#50 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#51 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#52 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#53 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#54 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#56 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#57 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(699): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#58 ../vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#59 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(246): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#60 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#61 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#62 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#63 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#64 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#65 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#66 ../vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#67 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#68 ../vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#69 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#70 ../vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#71 ../vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(515): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#72 ../tests/MyTest.php(47): Illuminate\Foundation\Testing\TestCase->call('GET', '/')
#73 [internal function]: MyTest->testPageControllerGet()
#74 ../vendor/phpunit/phpunit/src/Framework/TestCase.php(909): ReflectionMethod->invokeArgs(Object(MyTest), Array)
#75 ../vendor/phpunit/phpunit/src/Framework/TestCase.php(768): PHPUnit_Framework_TestCase->runTest()
#76 ../vendor/phpunit/phpunit/src/Framework/TestResult.php(612): PHPUnit_Framework_TestCase->runBare()
#77 ../vendor/phpunit/phpunit/src/Framework/TestCase.php(724): PHPUnit_Framework_TestResult->run(Object(MyTest))
#78 ../vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#79 ../vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#80 ../vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#81 ../vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#82 ../vendor/phpunit/phpunit/src/TextUI/Command.php(100): PHPUnit_TextUI_Command->run(Array, true)
#83 ../vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#84 {main}
My:
.env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
config/database.php
<?php
return [
'fetch' => PDO::FETCH_CLASS,
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'mysql'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
],
'migrations' => 'migrations',
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
<exclude>
<file>./app/Http/routes.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_HOST" value="mysql"/>
<env name="DB_USERNAME" value="homestead"/>
<env name="DB_PASSWORD" value="secret"/>
</php>
</phpunit>
Please help!
try an other version much easier. It is based in PHP 7 and is ready to run phpunit tests in one comand dunit
$ dstop
$ git checkout builder
$ . ./aliases.sh
$ dup
$ dunit
I think there are 2 things happening in your code snippet.
The first thing is that you are defining the host as mysql, not the driver (which i think is the one you are trying to set). Try setting the environment variable DB_CONNECTION to mysql instead of DB_HOST.
The second thing is that you need to add the DatabaseMigrations trait to your test class, try adding this:
<?php
// Imports
class MyTest extends TestCase {
use DatabaseMigrations; // This line
...
}
Without this your tests will probably fail as it will find the database, but it won't find any tables created inside it.
Hope it helps.
EDIT
Best practice for testing is to either mock dependencies that need to communicate with the database, or use an in-memory database for your tests to separate them from your real database.
In order to separate your testing database from your real database, you could use the sqlite driver in memory. Just update your sqlite driver in your database.php file like this:
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
And use it as the DB_CONNECTION environment variable in your tests (modifying phpunit.xml):
<env name="DB_CONNECTION" value="sqlite"/>
try this:
see if mysql container is up:
docker ps
You should see a mysql container. If not then run dstop & dup

Categories