PageRenderTime 25ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/README.md

https://bitbucket.org/mkalkbrenner/homebrew-php
Markdown | 222 lines | 146 code | 76 blank | 0 comment | 0 complexity | 995184e187c17ecdbca23741baca5a87 MD5 | raw file
  1. # Homebrew-PHP
  2. A centralized repository for PHP-related brews.
  3. ## Common Issues
  4. Bugs inevitably happen - none of us is running EVERY conceivable setup - but hopefully the install process can be made smoother through the following tips:
  5. - Upgrade your Mac to the latest patch version. So if you are on `10.7.0`, upgrade to `10.7.4` etc.
  6. - Ensure XCode is installed and up to date.
  7. - Run `brew update`. If you tapped an old version of `homebrew-php` or have an old brew installation, this may cause some installation issues.
  8. - Run `brew upgrade`. This will upgrade all installed formulae. Sometimes an old version of a formula is installed and this breaks our dependency management. Unfortunately, there is currently no way to force homebrew to upgrade only those we depend upon. This is a possible fix for those with `libxml` related compilation issues.
  9. - If `brew doctor` complains about `Error: Failed to import: homebrew-php-requirement` or similar, you can find broken php requirement files using `find $(brew --prefix)/Library/Formula -type l -name "*requirement.rb"`. Run this with the `-delete` flag if you are sure the results of the find contain only the files producing import failures. You can also remove them manually.
  10. - If you are using XCode 4, install the `Command Line Tools`. If you think you have it installed, please ensure that an update of XCode or OS X did not remove them. You can verify this by launching XCode, opening preferences, going to the Downloads tab, and clicking the `Install` button:
  11. ![command line tool installation](http://f.cl.ly/items/411X3k0m2O1p1U2Y0I30/Image%202012.11.15%2011:32:41%20AM.png)
  12. - Delete your `~/.pearrc` file before attempting to install a `PHP` version, as the pear step will fail if an existing, incompatible version exists. We try to detect and remove them ourselves, but sometimes this fails.
  13. - Run `brew doctor` and fix any issues you can.
  14. - If you are using Mountain Lion `10.8.x`, please install [XQuartz](http://xquartz.macosforge.org/landing/) so that the `png.h` header exists for compilation of certain brews. Mountain Lion removes X11, which contained numerous headers. A permanent fix is forthcoming.
  15. - If you upgraded to Mountain Lion `10.8.x`, please also upgrade to the latest XCode, 4.4.
  16. - File an awesome bug report, using the information in the next section.
  17. Doing all of these might be a hassle, but will more than likely ensure you either have a working install or get help as soon as possible.
  18. ----
  19. **SUPERHACK DANGEROUS DONT DO IT**
  20. If none of the above works, and we are unable to fix your issue after you've filed a bug report, try installing the [`OS X GCC Installer`](https://github.com/kennethreitz/osx-gcc-installer/). A small number of users have reported success after doing so.
  21. ----
  22. ### Filing Bug Reports
  23. Please include the following information in your bug report:
  24. - OS X Version: ex. 10.7.3, 10.6.3
  25. - Homebrew Version: `brew -v`
  26. - PHP Version in use: stock-apple, homebrew-php stable, homebrew-php devel, homebrew-php head, custom
  27. - XCode Version: 4.4, 4.3, 4.0, 3 etc.
  28. - If you are on Mountain Lion `10.8.x`, please also upgrade to the latest XCode, 4.4.
  29. - If using 4.3, verify whether you have the `Command Line Tools` installed as well
  30. - If on Snow Leopard, you may want to install the [`OS X GCC Installer`](https://github.com/kennethreitz/osx-gcc-installer/)
  31. - Output of `gcc -v`
  32. - Output of `php -v`
  33. - Output of `brew install -V path/to/homebrew-php/the-formula-you-want-to-test.rb --with-your --opts-here` within a [gist](http://gist.github.com). Please append any options you added to the `brew install` command.
  34. - Output of `brew doctor` within a [gist](http://gist.github.com)
  35. This will help us diagnose your issues much quicker, as well as find commonalities between different reported issues.
  36. ## Background
  37. This repository contains **PHP-related** formulae for [Homebrew](https://github.com/mxcl/homebrew).
  38. (This replaces the php formulae that used to live under [adamv's homebrew-alt repository](https://github.com/adamv/homebrew-alt).)
  39. The purpose of this repository is to allow PHP developers to quickly retrieve
  40. working, up-to-date formulae. The mainline homebrew repositories are maintianed
  41. by non-php developers, so testing/maintaining PHP-related brews has fallen by
  42. the wayside. If you are a PHP developer using homebrew, please contribute to
  43. this repository.
  44. ## Requirements
  45. * Homebrew
  46. * Snow Leopard, Lion, Mountain Lion. Untested everywhere else
  47. * The homebrew `dupes` tap - `brew tap homebrew/dupes`
  48. ## Installation
  49. _[Brew Tap]_
  50. Setup the `homebrew/dupes` tap which has dependencies we need:
  51. brew tap homebrew/dupes
  52. Then, run the following in your commandline:
  53. brew tap josegonzalez/homebrew-php
  54. ## Usage
  55. Tap the `homebrew/dupes` repository into your brew installation:
  56. brew tap homebrew/dupes
  57. Tap the repository into your brew installation:
  58. brew tap josegonzalez/homebrew-php
  59. **Note:** For a list of available configuration options run:
  60. brew options php54
  61. Then install php53, php54, or any formulae you might need:
  62. brew install php54
  63. That's it!
  64. Please also follow the instructions from brew info at the end of the install to ensure you properly installed your PHP version.
  65. ### Installing Multiple Versions
  66. Using multiple PHP versions from `homebrew-php` is pretty straightforward.
  67. If using Apache, you will need to update the `LoadModule` call. For convenience, simply comment out the old PHP version:
  68. # /etc/apache2/httpd.conf
  69. # Swapping from PHP53 to PHP54
  70. # $HOMEBREW_PREFIX is normally `/usr/local`
  71. # LoadModule php5_module $HOMEBREW_PREFIX/Cellar/php53/5.3.23/libexec/apache2/libphp5.so
  72. LoadModule php5_module $HOMEBREW_PREFIX/Cellar/php54/5.4.13/libexec/apache2/libphp5.so
  73. If using FPM, you will need to unload the `plist` controlling php, or manually stop the daemon, via your command line:
  74. # Swapping from PHP53 to PHP54
  75. # $HOMEBREW_PREFIX is normally `/usr/local`
  76. cp $HOMEBREW_PREFIX/Cellar/php54/5.4.13/homebrew-php.josegonzalez.php54.plist ~/Library/LaunchAgents/
  77. launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
  78. launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist
  79. If you would like to swap the PHP you use on the command line, you should update the `$PATH` variable in either your `.bashrc` or `.bash_profile`:
  80. # Swapping from PHP53 to PHP54
  81. # export PATH="$(brew --prefix josegonzalez/php/php53)/bin:$PATH"
  82. export PATH="$(brew --prefix josegonzalez/php/php54)/bin:$PATH"
  83. Please be aware that you must make this type of change EACH time you swap between PHP `minor` versions. You will typically only need to update the Apache/FPM when upgrading your php `patch` version.
  84. ### PEAR Extensions
  85. If installing `php53` or `php54`, please note that all extensions installed with the included `pear` will be installed to the respective php's bin path. For example, supposing you installed `PHP_CodeSniffer` as follows:
  86. pear install PHP_CodeSniffer
  87. It would be nice to be able to use the `phpcs` command via commandline, or other utilities. You will need to add the installed php's `bin` directory to your path. The following would be added to your `.bashrc` or `.bash_profile` when running the `php54` brew:
  88. export PATH="$(brew --prefix php54)/bin:$PATH"
  89. Some caveats:
  90. - Remember to use the proper php version in that export. So if you installed the `php53` formula, use `php53` instead of `php54` in the export.
  91. - Updating your installed php will result in the binaries no longer existing within your path. In such cases, you will need to reinstall the pear extensions. Alternatives include installing `pear` outside of `homebrew-php` or using the `homebrew-php` version of your extension.
  92. - Uninstalling your `homebrew-php` php formula will also remove the extensions.
  93. ## Contributing
  94. The following kinds of brews are allowed:
  95. - PHP Extensions: They may be built with PECL, but installation via homebrew is sometimes much easier.
  96. - PHP Utilities: php-version, php-build fall under this category
  97. - Common PHP Web Applications: phpmyadmin goes here. Note that Wordpress would not because it requires other migration steps, such as database migrations etc.
  98. - PHP Frameworks: These are to be reviewed on a case-by-case basis. Generally, only a recent, stable version of a popular framework will be allowed.
  99. If you have any concerns as to whether your formula belongs in PHP, just open a pull request with the formula and we'll take it from there.
  100. ### PHP Extension definitions
  101. PHP Extensions MUST be prefixed with `phpVERSION`. For example, instead of the `Solr` formula for PHP54 in `solr.rb`, we would have `Php54Solr` inside of `php54-solr.rb`. This is to remove any possible conflicts with mainline homebrew formulae.
  102. The template for the `php54-example` pecl extension would be as follows. Please use it as an example for any new extension formulae:
  103. require File.join(File.dirname(__FILE__), 'abstract-php-extension')
  104. class Php54Example < AbstractPhp54Extension
  105. init
  106. homepage 'http://pecl.php.net/package/example'
  107. url 'http://pecl.php.net/get/example-1.0.tgz'
  108. sha1 'SOMEHASHHERE'
  109. version '1.0'
  110. head 'https://svn.php.net/repository/pecl/example/trunk', :using => :svn
  111. def install
  112. Dir.chdir "example-#{version}" unless build.head?
  113. ENV.universal_binary if build.universal?
  114. safe_phpize
  115. system "./configure", "--prefix=#{prefix}",
  116. phpconfig
  117. system "make"
  118. prefix.install "modules/example.so"
  119. write_config_file unless build.include? "without-config-file"
  120. end
  121. end
  122. Before testing the extension, you will need run the command `brew tap --repair` to create a symlink in `$HOMEBREW_PREFIX/Library/Formula`.
  123. Defining extensions inheriting AbstractPhp5(34)Extension will provide a `write_config_file` which add `ext-{extension}.ini` to `conf.d`, dont forget to remove it manually upon extension removal. Please see [AbstractPhpExtension.rb](Formula/AbstractPhpExtension.rb) for more details.
  124. Please note that your formula installation may deviate significantly from the above; caveats should more or less stay the same, as they give explicit instructions to users as to how to ensure the extension is properly installed.
  125. The ordering of Formula attributes, such as the `homepage`, `url`, `sha1`, etc. should follow the above order for consistency. The `version` is only included when the url does not include a version in the filename. `head` installations are not required.
  126. All official PHP extensions should be built for all stable versions of PHP included in `homebrew-php`. As of this writing, these version are `5.3.23` and `5.4.13`.
  127. ## Todo
  128. * ~~Proper PHP Versioning? See issue [#1](https://github.com/josegonzalez/homebrew-php/issues/8)~~
  129. * ~~Pull out all PHP-related brews from Homebrew~~
  130. ## License
  131. Copyright (c) 2012 Jose Diaz-Gonzalez and other contributors
  132. Permission is hereby granted, free of charge, to any person obtaining a copy
  133. of this software and associated documentation files (the "Software"), to deal
  134. in the Software without restriction, including without limitation the rights
  135. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  136. copies of the Software, and to permit persons to whom the Software is
  137. furnished to do so, subject to the following conditions:
  138. The above copyright notice and this permission notice shall be included in
  139. all copies or substantial portions of the Software.
  140. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  141. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  142. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  143. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  144. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  145. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  146. THE SOFTWARE.