orchestral/testbench

Add `LARAVEL_START`

Closed this issue · 4 comments

Hi!

My commands rely on LARAVEL_START so that I can constantly keep an eye out for performance issues. Can also define it so that my code don't have to work around it? I can PR.

Thank you!

what 's the use case?

  1. My custom artisan commands always show the amount of time taken from LARAVEL_START until exit, so that all developers are exposed to this simple performance metric constantly.

  2. One of the command is a overridden version of migrate:fresh which is executed during our CI/CD and because it cannot find LARAVEL_START, the test fails.

  3. I suppose define('LARAVEL_START', microtime(true)); at the start of testbench's first PHP file would have minimal impact, right?

I added define('LARAVEL_START', microtime(true)); at your location, but it did not solve my problem.

Eventually, I fixed it by adding define('LARAVEL_START', microtime(true)); at these locations

For Laravel projects

https://github.com/laravel/framework/blob/c6aeffded35c10ac60b14d4cff4b6c45dc57e9ea/src/Illuminate/Foundation/Testing/TestCase.php#L85

For Laravel packages

The equivalent in testbench-core would be https://github.com/orchestral/testbench-core/blob/158e2f483bccab28f36d6170a551641534813886/src/TestCase.php#L48

Or is there a better place to define LARAVEL_START?