Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First request display all information, nexts don't #10

Closed
lyrixx opened this issue Mar 30, 2019 · 2 comments
Closed

First request display all information, nexts don't #10

lyrixx opened this issue Mar 30, 2019 · 2 comments

Comments

@lyrixx
Copy link

lyrixx commented Mar 30, 2019

Hello.

First, thanks a lot for this lib :D

Then, I would like to try few things with this lib (more to come) but I'm facing something strange. So I would like to know if this "normal".

I installed the lib as described in the INSTALL.md (BTW you don't tell about loading the extension in the php.ini or with something like -dextension=/home/gregoire/dev/labs/candle/pcov/modules/pcov.so).

Afterwards, I created a fresh Symfony project (composer create-project symfony/website-skeleton demo -s dev master -vvv),
and added a simple entity + controller (CRUD) with the make bundle. Anyway :)

In the frontend controller I did that:

diff --git a/public/index.php b/public/index.php
index e30f90c..fa0c10c 100644
--- a/public/index.php
+++ b/public/index.php
@@ -4,6 +4,8 @@ use App\Kernel;
 use Symfony\Component\Debug\Debug;
 use Symfony\Component\HttpFoundation\Request;

+\pcov\start();
+
 require dirname(__DIR__).'/config/bootstrap.php';

 if ($_SERVER['APP_DEBUG']) {
@@ -23,5 +25,6 @@ if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false
 $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
 $request = Request::createFromGlobals();
 $response = $kernel->handle($request);
+echo json_encode(\pcov\collect());die;
 $response->send();
 $kernel->terminate($request, $response);

If you don't know Symfony, I'm basically starting the coverage report ASAP, and then I dump the report instead if the regular response.

On the very first run, I got something like:

{"\/home\/gregoire\/dev\/labs\/candle\/demo\/src\/Kernel.php":{"49":1,"18":1,"20":1,"21":1,"22":1,"23":1,"26":1,"30":-1,"31":-1,"32":-1,"34":-1,"35":-1,"36":-1,"37":-1,"38":-1,"42":-1,"44":-1,"45":-1,"46":-1,"47":-1},"\/home\/gregoire\/dev\/labs\/candle\/demo\/src\/Controller\/PostController.php":{"97":1,"23":1,"24":1,"33":-1,"34":-1,"35":-1,"37":-1,"38":-1,"39":-1,"40":-1,"42":-1,"45":-1,"46":-1,"47":-1,"56":-1,"57":-1,"66":-1,"67":-1,"69":-1,"70":-1,"72":-1,"73":-1,"77":-1,"78":-1,"79":-1,"88":-1,"89":-1,"90":-1,"91":-1,"94":-1},"\/home\/gregoire\/dev\/labs\/candle\/demo\/src\/Repository\/PostRepository.php":{"51":1,"19":1,"20":1},"\/home\/gregoire\/dev\/labs\/candle\/demo\/src\/Entity\/Post.php":{"58":1,"31":-1,"36":-1,"41":-1,"43":-1,"48":-1,"53":-1,"55":-1}}

This is perfect, and thanks again :D

But, on next runs, I got something like:

[]

At the first glance, I thought it might be caused by OPCache, so I removed it.
But it did not change anything. So I removed Blackfire, and (OH I did not notice
that before) XDebug. Still the same result.

So, to me this is strange, that's why I would like to know what I'm doing wrong.

Note about my arch
# php -v
PHP 7.3.3-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar  7 2019 20:31:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
# release
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

I'm using the cli-server SAPI through Symfony. But Symfony does not transfer all PHP config to the "server"
I had to manually edit WebsServer.php:

$process = new Process(array_merge(
    [$binary],
    $finder->findArguments(),
    $xdebugArgs,
    ['-dextension=/home/gregoire/dev/labs/candle/pcov/modules/pcov.so'], // I added that
    ['-dpcov.directory=/home/gregoire/dev/labs/candle/demo/src'], // And that
    ['-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()],
));

I hope you have all information to solve this issue ❤️

krakjoe added a commit that referenced this issue Mar 30, 2019
@krakjoe
Copy link
Owner

krakjoe commented Mar 30, 2019

Above commit should fix it, can you please confirm ?

@lyrixx
Copy link
Author

lyrixx commented Mar 30, 2019

Yes, Thank you 👍

@lyrixx lyrixx closed this as completed Mar 30, 2019
@krakjoe krakjoe mentioned this issue Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants