{"id":1204,"date":"2016-08-24T10:15:55","date_gmt":"2016-08-24T10:15:55","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=1204"},"modified":"2017-06-14T11:33:55","modified_gmt":"2017-06-14T11:33:55","slug":"configure-blackfire-profiler-for-your-php-application","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/","title":{"rendered":"Configure Blackfire profiler for your php application&#8230;!!!"},"content":{"rendered":"<p lang=\"en-US\">What is Blackfire ?<\/p>\n<p lang=\"en-US\">Blackfire is a web app profiler tool that helps you to debug your application &amp; optimize its performance. Once you install &amp; configure it on your server, it will tell you the complete performance of your php app like it will show you the I\/O, memory consumption, CPU Time. When you will hit your php app in browser &amp; start profiling your app through blackfire tool, you will get an option &#8220;view profile&#8221;, just click on that option and get the complete result of your app in which it will visualize you how your app runs &amp; calling php functions step by step. In short i would say, It highlights important pathways so you can focus on the relevant parts of your php app.<\/p>\n<p lang=\"en-US\">Ok now lets install this tool on server&#8230;!!!!<\/p>\n<p lang=\"en-US\"><strong>Pre-requisites<\/strong><\/p>\n<ul>\n<li style=\"padding-left: 30px\">Blackfire Companion is available only on Chrome Browser.<\/li>\n<li style=\"padding-left: 30px\">Blackfire Agent &amp; client works on Linux, Windows &amp; MacOS X.<\/li>\n<li style=\"padding-left: 30px\">The Probe works on Linux, Windows &amp; MacOS X with PHP 5.3, 5.4, 5.5, 5.6, and 7.0.<\/li>\n<\/ul>\n<p lang=\"en-US\">Now i will install it on ubuntu, here are the steps of installation on ubuntu os:-<\/p>\n<p lang=\"en-US\">Register the pagecloud key with the command:-<\/p>\n<pre class=\"lang:default decode:true \">wget -O - https:\/\/packagecloud.io\/gpg.key | sudo apt-key add -<\/pre>\n<p lang=\"en-US\">Add deb http:\/\/packages.blackfire.io\/debian any main to \/etc\/apt\/sources.list.d\/blackfire.list with the command:<\/p>\n<pre class=\"lang:default decode:true \">echo \"deb http:\/\/packages.blackfire.io\/debian any main\" | sudo tee \/etc\/apt\/sources.list.d\/blackfire.list<\/pre>\n<p lang=\"en-US\">now run update command:-<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get update<\/pre>\n<p lang=\"en-US\">Now install blackfire agent with the command:-<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get install blackfire-agent<\/pre>\n<p lang=\"en-US\">after installation, just register blackfire agent with the command:-<\/p>\n<pre class=\"lang:default decode:true \">sudo blackfire-agent -register<\/pre>\n<p lang=\"en-US\">after hitting previous command, It will ask you to enter server id &amp; server token. You will have to generate it by <a href=\"https:\/\/blackfire.io\/signup?target=\/docs\/up-and-running\/installation\">log in<\/a> or <a href=\"https:\/\/blackfire.io\/signup?target=\/docs\/up-and-running\/installation\">signup<\/a> your account in its official site.<\/p>\n<p lang=\"en-US\">After <a href=\"https:\/\/blackfire.io\/signup?target=\/docs\/up-and-running\/installation\">log in<\/a> or <a href=\"https:\/\/blackfire.io\/signup?target=\/docs\/up-and-running\/installation\">sighup<\/a>, go to the dropdown : click on Account option &amp; here you will get all credentials needed while installation. Get the server id &amp; server token from there and register it.<\/p>\n<p lang=\"en-US\">Now run the command mentioned below to initialize the client:-<\/p>\n<pre class=\"lang:default decode:true \">blackfire config<\/pre>\n<p lang=\"en-US\">After hitting previous command, It will ask you to enter client id &amp; client token. You will get these credentials from the same where you login &amp; got your server id &amp; server token.<\/p>\n<p lang=\"en-US\">Now Install the blackfire php package by hitting:-<\/p>\n<pre class=\"lang:default decode:true \">sudo apt-get install blackfire-php<\/pre>\n<p lang=\"en-US\">After installing blackfire php package. You will need to configure for the PHP probe in your php.ini file placed in \/etc\/php5\/cli\/php.ini path.<\/p>\n<p lang=\"en-US\">If you are using php7.0 then your php.ini file will be placed in \/etc\/php\/7.0\/cli\/php.ini path. If you don&#8217;t get your php.ini file in any path mentioned here, go &amp; hit the command to know where it is located by typing:<\/p>\n<pre class=\"lang:default decode:true\">php --ini<\/pre>\n<p lang=\"en-US\">open your php.ini file (with sudo user) :-<\/p>\n<pre class=\"lang:default decode:true\">sudo nano \/etc\/php5\/cli\/php.ini<\/pre>\n<p lang=\"en-US\">and add the following:-<\/p>\n<pre class=\"lang:default decode:true  \">[blackfire]\r\n\r\nextension=\"\/usr\/lib\/blackfire-php\/amd64\/blackfire-20151012.so\"\r\n; Sets the socket where the agent is listening.\r\n\r\n; Possible value can be a unix socket or a TCP address.\r\n\r\n; Defaults to unix:\/\/\/var\/run\/blackfire\/agent.sock on Linux,\r\n\r\n; unix:\/\/\/usr\/local\/var\/run\/blackfire-agent.sock on MacOSX,\r\n\r\n; and to tcp:\/\/127.0.0.1:8307 on Windows.\r\n\r\n;blackfire.agent_socket = unix:\/\/\/var\/run\/blackfire\/agent.sock\r\n\r\nblackfire.agent_timeout = 0.25\r\n\r\n; Log verbosity level (4: debug, 3: info, 2: warning, 1: error)\r\n\r\n;blackfire.log_level = 1\r\n\r\n; Log file (STDERR by default)\r\n\r\n;blackfire.log_file = \/tmp\/blackfire.log\r\n\r\n;blackfire.server_id =\r\n\r\n;blackfire.server_token =<\/pre>\n<p lang=\"en-US\">Now restart your blackfire agent by typing:-<\/p>\n<pre class=\"lang:default decode:true \">sudo \/etc\/init.d\/blackfire-agent restart<\/pre>\n<p lang=\"en-US\">Now go to your chrome browser, search &amp; install Blackfire Companion extension.<\/p>\n<p lang=\"en-US\">After successfully installing the extension, just hit your server&#8217;s domain in which you have configured blackfire &amp; then you will get something like:-<\/p>\n<p lang=\"en-US\"><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/first.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1221\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/first.png\" alt=\"first\" width=\"668\" height=\"421\" \/><\/a><\/p>\n<p lang=\"en-US\">Click on Profile:-<\/p>\n<p lang=\"en-US\"><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/second.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1223\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/second.png\" alt=\"second\" width=\"1373\" height=\"442\" \/><\/a><\/p>\n<p lang=\"en-US\">After profiling the url of your server. It will display you the summary of your profile.<\/p>\n<p lang=\"en-US\"><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/third.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1224\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/third.png\" alt=\"third\" width=\"1372\" height=\"443\" \/><\/a><\/p>\n<p lang=\"en-US\">It will provide you some basic information like:-<\/p>\n<p lang=\"en-US\">388 ms is the time for php to generate the homepage.<\/p>\n<p lang=\"en-US\">6.82 ms is I\/O time.<\/p>\n<p lang=\"en-US\">381 ms is the CPU time.<\/p>\n<p lang=\"en-US\">5.44 MB is the amount of memory consumed by PHP.<\/p>\n<p lang=\"en-US\">After that if you click on view profile. You will be redirected to the detailed profile on Blackfire.io.<\/p>\n<p lang=\"en-US\">Your profile page will be look like :-<\/p>\n<p lang=\"en-US\"><a href=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/last.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1222\" src=\"http:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/last.png\" alt=\"last\" width=\"1532\" height=\"811\" \/><\/a><\/p>\n<p lang=\"en-US\">From here you can check the most time consuming function calls &amp; analyze your complete code which is taking too much time to load.<\/p>\n<p lang=\"en-US\"><span style=\"color: #ff0000\"><strong>Note:-<\/strong><\/span><\/p>\n<ol>\n<li>PHP compiled with debug are not supported and that the Probe may conflict with XDebug or XHProf, disable those extensions when enabling the Probe. The Probe conflicts with some PHP extensions like Pinba.<\/li>\n<li>Support for ZTS versions of PHP on MacOS X is currently in beta.<\/li>\n<\/ol>\n<p style=\"text-align: center\"><strong><a href=\"http:\/\/cloudkul.com\/contact\/\" target=\"_blank\">FOR ANY TYPE OF QUERY OR HELP, KINDLY CONTACT US<\/a><\/strong><\/p>\n<p style=\"text-align: center\">\n","protected":false},"excerpt":{"rendered":"<p>What is Blackfire ? Blackfire is a web app profiler tool that helps you to <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":4,"featured_media":1237,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[21],"tags":[57,28],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Configure Blackfire profiler for your php application...!!! - Cloudkul<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configure Blackfire profiler for your php application...!!! - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"What is Blackfire ? Blackfire is a web app profiler tool that helps you to [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-24T10:15:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:33:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/Banner.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prashant Arora\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/\",\"name\":\"Configure Blackfire profiler for your php application...!!! - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2016-08-24T10:15:55+00:00\",\"dateModified\":\"2017-06-14T11:33:55+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/0f130d5c45f7a843f035c2b26dfd8822\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configure Blackfire profiler for your php application&#8230;!!!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/0f130d5c45f7a843f035c2b26dfd8822\",\"name\":\"Prashant Arora\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ffd3d12ef1ac706011cfd6f835707402?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ffd3d12ef1ac706011cfd6f835707402?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Prashant Arora\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/prashant089\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Configure Blackfire profiler for your php application...!!! - Cloudkul","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/","og_locale":"en_US","og_type":"article","og_title":"Configure Blackfire profiler for your php application...!!! - Cloudkul","og_description":"What is Blackfire ? Blackfire is a web app profiler tool that helps you to [...]","og_url":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/","og_site_name":"Cloudkul","article_published_time":"2016-08-24T10:15:55+00:00","article_modified_time":"2017-06-14T11:33:55+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/08\/Banner.png","type":"image\/png"}],"author":"Prashant Arora","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/","url":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/","name":"Configure Blackfire profiler for your php application...!!! - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2016-08-24T10:15:55+00:00","dateModified":"2017-06-14T11:33:55+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/0f130d5c45f7a843f035c2b26dfd8822"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/configure-blackfire-profiler-for-your-php-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Configure Blackfire profiler for your php application&#8230;!!!"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/0f130d5c45f7a843f035c2b26dfd8822","name":"Prashant Arora","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ffd3d12ef1ac706011cfd6f835707402?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ffd3d12ef1ac706011cfd6f835707402?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Prashant Arora"},"url":"https:\/\/cloudkul.com\/blog\/author\/prashant089\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/1204"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=1204"}],"version-history":[{"count":28,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/1204\/revisions"}],"predecessor-version":[{"id":1667,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/1204\/revisions\/1667"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/1237"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=1204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=1204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=1204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}