![]() ![]() _DIR_.'/./symfony/symfony' instead of the not-possible-to-optimize $vendorDir.'/symfony/symfony' dynamic version. For composer, this means that the path of directories can be constructed using interned strings declared as e.g. Thanks to them, PHP can concatenate strings at the compilation stage. Here comes PHP 5.6 and constant expressions. It can’t save the execution of the byte-codes that construct the corresponding PHP arrays. This is true even if you have OPcache enabled, because in this case OPcache is only able to save the compilation of the classmaps. For each request, these classmaps are executed, and for each request they take a few MB of memory. On PHP 5.5 or with a non-patched composer script, the classmap (and all smaller internal maps generated by composer) are loaded in memory for each request. Before composer went patched to take advantage of them. Before PHP 5.6/7.0 implemented immutable arrays and constant expressions. Even with OPcache enabled, the classmap is a plain PHP array that becomes slower to load when you add more classes to it…īut that was before. If you follow established best practices (or Blackfire’s own recommendations), you know that dumping the classmap (in authoritative mode) generates the fastest autoloader: it reduces autoloading to an isset() check, one of the fastest in PHP.īut this classmap doesn’t scale when your app gets bigger. ![]() Nowadays, almost everyone uses composer to install their dependencies, don’t you? This means that composer’s ClassLoader implementation is likely the most universal piece of code running on the PHP engine, all versions included. Of course, this number varies a lot and that’s maybe not what you’ve seen in you own app, but a typical 10% wouldn’t be surprising. What I’ve learned profiling so many PHP apps is that autoloading takes a significant amount of resources. I recommend to add another alias for Blackfire to use the full php path including configuration so that you don't have to run it the following way: blackfire run /Applications/MAMP/bin/php/php7.3.8/bin/php -c /Applications/MAMP/bin/php/php7.3.8/conf/php.As the CTO of Blackfire, I do a lot of performance profiles: both to enhance the product and just as a regular user who wants to understand ones software behavior. Verify that the extension is installed through running php -ri blackfire Replace with your extension path (different for every php version)Įxtension="/Applications/MAMP/bin/php/php7.3.8/lib/php/extensions/no-debug-non-zts-20180731/blackfire.so"īlackfire.agent_socket = unix:///usr/local/var/run/blackfire-agent.sockīrver_token = If you use the MAMP templates, add it there. Now put the following configuration with your api key and secret (the ones you get from Blackfire) at the end of your php.ini. ![]() Change into the director and copy the blackfire.so to your extension directory with: cp blackfire.so /Applications/MAMP/bin/php/php7.3.8/lib/php/extensions/no-debug-non-zts-20180731/blackfire.so This will result in the blackfire.so file to be installed to /usr/local/Cellar/blackfire-php73/1.27.1/ (depending on the version the path will change, but you get the gist). Replace php73 with whatever version you're using. The best way to download that is to use homebrew with the following command: brew install blackfire-php73 -without-homebrew-php In the documentation you find the probe, but you won't find the blackfire.so file. alias php="/Applications/MAMP/bin/php/php7.3.8/bin/php -c /Applications/MAMP/bin/php/php7.3.8/conf/php.ini" I have php symlinked to use the MAMP version in iTerm and the specific php.ini in my profile. This is important if you also want to run blackfire on the console. Unfortunately it misses one part which through me off at the beginning.įirst of all, check if you've configured your MAMP to use a separate php.ini (one for Apache and one for the console). In general the Blackfire documentation is quite good and also includes a description how to do a manual installation. It only means that there are not much resources online about how to setup Blackfire there. But that doesn't mean that you're not a pro when using MAMP or that Blackfire is only useful for "professionals". Blackfire is kind of a profiler for pro users and MAMP Pro is used mostly for starters. ![]()
0 Comments
Leave a Reply. |