test comman works in terminal but not in php - laravel

When i execute php artisan test --testsuite=myTestsuite in the terminal i get the right result which is just this testsuite exucuted with its tests.
But when i execute php artisan myCommand:
Then the testsuite which is listed first in the phpunit.xml is executed first and then the one which i passed the name.
Has somebody an idea why this is happening?

To call artisan in command you need to use next construction:
$this->call('test', ['test suite' => 'MyTestsuite']);

solved it with
shell_exec('php artisan test --testsuite=MyTestsuite')
if somebody finds a other solution please let me know. Thanks

you can use the Artisan facade like the below:
Artisan::call('test --testsuite=myTestsuite');
$output = Artisan::output();

Related

Laravel db:seed does not work without --class parameter

Running php artisan db:seed does not work for some reason on my Laravel 5.6 project.
The command runs (quietly) even without a database
Does not return any error on the terminal
However, when I run php artisan db:seed --class=ClassNameTableSeeder it works. What could be the cause of such a weird behavior?
NB : Similar to questions like 39521913 but not a duplicate.
This is because by default DatabaseSeeder does nothing. Original code in fresh Laravel project looks like this:
public function run()
{
// $this->call(UsersTableSeeder::class);
}
So to run any database seeder, you should uncomment this line and put valid class name, so for example:
$this->call(ClassNameTableSeeder1::class);
$this->call(ClassNameTableSeeder2::class);
and so on to run seeders for each class you put here.

PhpStorm can't find Laravel helpers

I use PhpStorm 2018.1.4. I installed the package laravel-ide-helper. This allows PhpStorm to see model methods, but it doesn't see any chaining methods from Laravel helpers. For example, I have the following code in the controller:
return response()->file($path,['content-type' => 'application/pdf']);
PhpStorm says to me:
Method 'file' not found in \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response.
How to fix it?
UPD: Of course, after install the package, I ran thees artisan commands:
php artisan ide-helper:generate
php artisan ide-helper:meta
Installing the laravel-ide-helper alone doesn't do anything. You need to run the artisan commands to generate the files that phpstorm will use.
php artisan ide-helper:generate
and
php artisan ide-helper:meta
Will help phpStorm's auto-completion.
Update: Since these are executed, the actual problem is a laravel structure issue:
The helper file() doesn't actually exist in the ResponseFactory (response() returns result of ResponseFactory) so IDE helper can't map to it.
file() does however exist in the Facade so if you were to do:
\Response::file($path,['content-type' => 'application/pdf']) it will auto complete.
It's a work around, but unless file() gets added to the response factory at laravel's level, there's not much ide helper or phpstorm can do.

laravel 5.2 config constant does not work on server

i seperate my strings and put them in Constant directory in textConstant.php file , in my localhost everythings are okey but when i uploads my code on my server the string fade out and nothing show in my screen ,
here is my constant file :
return [
'title' => 'test',
'book' => 'book_test',
];
and here is my code that use constant :
<button>{{config('Constants.textConstant.book')}}</button>
please help me to solve my problem because my site cannot be usable, thanks alot :)
Try to run the following code over commandline if you have enabled the cache.
php artisan config:clear
php artisan config:cache.
In CMD;
Write first
php artisan config:clear
Then
php artisan config:cache
Hope this will work.

How to fix [ErrorException] the use statement with non-compound name 'App' has no effect error displayed on cmd when php artisan serve command run

When I try php artisan serve command at my terminal it gives below error.Can any body help me to fix this issue?
ErrorException
The use statement with non-compound name 'App' has no effect
remove
use App;
from your route.php file, it will work for sure. Thanks.
I hereby post the answer for my own question as I found answer for this and hope this may helpful others in future.
Before : I just used 'use App' only at routes.php
Now : When use 'use App\Http\Controllers' problem solved.
Probably you add 'use App;' in some of your Laravel files, and artisan is parsing the line as an error.
To know which line/file is the error, go to the log file (storage/logs/) and check it out. Then remove that line from the file.

All artisan commands fail to run. Including php artisan list

I'm getting no output from php artisan.
I have checked laravel logs and php logs. I'm getting no errors it just fails silently.
I also added dumps to the artisan file and they all show on the console except when I try one after this bit of code.
$status = $kernel->handle( $input = new Symfony\Component\Console\Input\ArgvInput, new Symfony\Component\Console\Output\ConsoleOutput );
I'm running L5.0 on php 5.4.41
Any idea whats going on here?
Have you tried running composer update and re-checking the commands? It should do it :)

Resources