{"id":3310,"date":"2013-09-15T16:44:46","date_gmt":"2013-09-15T15:44:46","guid":{"rendered":"http:\/\/www.haydnwilliams.com\/blog\/?p=3310"},"modified":"2022-04-11T21:33:13","modified_gmt":"2022-04-11T20:33:13","slug":"upgrading-php-with-homebrew","status":"publish","type":"post","link":"https:\/\/www.haydnwilliams.com\/blog\/upgrading-php-with-homebrew\/","title":{"rendered":"Upgrading PHP with Homebrew"},"content":{"rendered":"<p>A while ago I used <a title=\"Homebrew - The missing package manager for OS X\" href=\"http:\/\/brew.sh\" target=\"_blank\" rel=\"noopener\">Homebrew<\/a> to install PHP and some associated tools (<a title=\"PHPUnit on Github\" href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/\" target=\"_blank\" rel=\"noopener\">PHPUnit<\/a> including DbUnit, <a title=\"PEAR - PHP Code Sniffer\" href=\"http:\/\/pear.php.net\/package\/PHP_CodeSniffer\/\" target=\"_blank\" rel=\"noopener\">PHP Code Sniffer<\/a>, <em>etc.<\/em>). Every time I need to install a new version of PHP I forget how to do it, so I&#8217;ve aggregated instructions from a number of sources into one page here.<\/p>\n<p>Note that the precise commands will vary with each version of PHP, so any involving a PHP version number refer to it below using an X, <em>e.g.<\/em> <strong>php5X<\/strong> might represent <strong>php55<\/strong>, while <strong>5.X.X<\/strong> might represent <strong>5.5.3<\/strong><\/p>\n<p>If you&#8217;re starting this process from scratch, <a title=\"Gist - OSX PHP Homebrew Setup\" href=\"https:\/\/gist.github.com\/niepi\/1932534\" target=\"_blank\" rel=\"noopener\">this Gist<\/a> (not mine) might prove more useful.<\/p>\n<h3>Update Brew:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">brew update\r\nbrew upgrade\r\nbrew doctor\r\n<\/pre>\n<p>Fix any problems which are highlighted by the last command.<br \/>\n<a title=\"Homebrew FAQ at Github\" href=\"https:\/\/github.com\/mxcl\/homebrew\/wiki\/FAQ\" target=\"_blank\" rel=\"noopener\">More info&#8230;<\/a><\/p>\n<h3>Install new PHP Version:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">brew tap homebrew\/dupes\r\nbrew tap josegonzalez\/homebrew-php\r\nbrew install php5X\r\nbrew doctor\r\nsudo vi \/usr\/local\/etc\/php\/5.X\/php.ini<\/pre>\n<p>After running the last command to start editing, search for <em>include_path<\/em> and set to: <em>include_path=&#8221;.:\/usr\/local\/Cellar\/php<X>;\/5.X.X\/lib\/php\/&#8221;<\/em><br \/>\n<a title=\"Homebrew PHP on Github\" href=\"https:\/\/github.com\/josegonzalez\/homebrew-php\" target=\"_blank\" rel=\"noopener\">More info&#8230;<\/a><\/p>\n<h3>Use the new PHP Version:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo vi \/etc\/apache2\/httpd.conf<\/pre>\n<p>Find <em>php5_module<\/em> and change to new path<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo \/usr\/sbin\/apachectl restart\r\nsudo vi ~\/.profile - change to new path\r\nsource ~\/.profile\r\nphp -v<\/pre>\n<p>Check that the last command showed that the new version of PHP is being used. Then open a web browser and use <em>phpinfo()<\/em> to check that Apache is also using the new version of PHP.<br \/>\n<a title=\"Homebrew PHP on Github\" href=\"https:\/\/github.com\/josegonzalez\/homebrew-php\" target=\"_blank\" rel=\"noopener\">More info&#8230;<\/a><\/p>\n<h3>XDEBUG:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">brew install php5X\r\nsudo \/usr\/sbin\/apachectl restart<\/pre>\n<p>Open a web browser and use <em>phpinfo() <\/em>to check that Apache is loading the xdebug module.<\/p>\n<h3>PHP Unit:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo pear channel-discover pear.phpunit.de\r\nsudo pear channel-discover pear.symfony.com\r\nsudo pear install --alldeps phpunit\/phpunit\r\nwhich phpunit<\/pre>\n<p>Check that the last command found a binary in a directory relating to the new version of PHP, <em>e.g.<\/em> <em>\/usr\/local\/opt\/php55\/bin<\/em>. Note that <em>\/usr\/local\/opt\/php5X<\/em> is just a symlink to <em>\/usr\/local\/Cellar\/php5X\/5.X.X<\/em><br \/>\n<a title=\"michaelheap.com - INSTALLING PHPUNIT UNDER PHP 5.4 FROM HOMEBREW\" href=\"http:\/\/michaelheap.com\/installing-phpunit-under-php-5-4-from-homebrew\/\" target=\"_blank\" rel=\"noopener\">More info&#8230;<\/a><\/p>\n<h3>DB Unit:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo pear install phpunit\/DbUnit\r\nwhich dbunit<\/pre>\n<p>Check that the last command found a binary in a directory relating to the new version of PHP, <em>e.g.<\/em> <em>\/usr\/local\/opt\/php55\/bin<\/em>. Note that <em>\/usr\/local\/opt\/php5X<\/em> is just a symlink to <em>\/usr\/local\/Cellar\/php5X\/5.X.X<\/em><br \/>\n<a title=\"PHPUnit Manual - Chapter 8. Database Testing\" href=\"http:\/\/phpunit.de\/manual\/3.8\/en\/database.html\" target=\"_blank\" rel=\"noopener\">More info&#8230;<\/a><\/p>\n<h3>PHP Code Sniffer:<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo pear install PHP_CodeSniffer\r\nwhich phpcs<\/pre>\n<p>Check that the last command found a binary in a directory relating to the new version of PHP, <em>e.g.<\/em> <em>\/usr\/local\/opt\/php55\/bin<\/em>. Note that <em>\/usr\/local\/opt\/php5X<\/em> is just a symlink to <em>\/usr\/local\/Cellar\/php5X\/5.X.X<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while ago I used Homebrew to install PHP and&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[988,987,989,236,249,866],"class_list":["post-3310","post","type-post","status-publish","format-standard","hentry","category-it","tag-brew","tag-homebrew","tag-install","tag-os-x","tag-php","tag-phpunit"],"_links":{"self":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/3310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/comments?post=3310"}],"version-history":[{"count":0,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/3310\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/media?parent=3310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/categories?post=3310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/tags?post=3310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}