Giter VIP home page Giter VIP logo

onion's Introduction

PHPBrew

Read this in other languages: English, Português - BR, 日本語, 中文.

build Coverage Status Gitter

phpbrew builds and installs multiple version php(s) in your $HOME directory.

What phpbrew can do for you:

  • Configure options are simplified into variants, no worries about the path anymore!
  • Build php with different variants like PDO, mysql, sqlite, debug ...etc.
  • Compile apache php module and separate them by different versions.
  • Build and install php(s) in your home directory, so you don't need root permission.
  • Switch versions very easily and is integrated with bash/zsh shell.
  • Automatic feature detection.
  • Install & enable php extensions into current environment with ease.
  • Install multiple php into system-wide environment.
  • Path detection optimization for HomeBrew and MacPorts.

Requirement

Please see Requirement before you get started. you need to install some development packages for building PHP.

QUICK START

Please see Quick Start if you're impatient. :-p

GETTING STARTED

OK, I assume you have more time to work on this, this is a step-by-step tutorial that helps you get started.

Installation

curl -L -O https://github.com/phpbrew/phpbrew/releases/latest/download/phpbrew.phar
chmod +x phpbrew.phar

# Move the file to some directory within your $PATH
sudo mv phpbrew.phar /usr/local/bin/phpbrew

Init a bash script for your shell environment:

phpbrew init

Add these lines to your .bashrc or .zshrc file:

[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc
  • Specifically for fish shell users, add following lines to your ~/.config/fish/config.fish file*:
source ~/.phpbrew/phpbrew.fish

If you're using system-wide phpbrew, you may setup a shared phpbrew root, for example:

mkdir -p /opt/phpbrew
phpbrew init --root=/opt/phpbrew

Setting up lookup prefix

You may setup your preferred default prefix for looking up libraries, available options are macports, homebrew, debian, ubuntu or a custom path:

For Homebrew users:

phpbrew lookup-prefix homebrew

For Macports users:

phpbrew lookup-prefix macports

Basic usage

To list known versions:

phpbrew known

8.2: 8.2.4, 8.2.3, 8.2.2, 8.2.1, 8.2.0 ...
8.1: 8.1.17, 8.1.16, 8.1.15, 8.1.14, 8.1.13, 8.1.12, 8.1.11, 8.1.10 ...
8.0: 8.0.28, 8.0.27, 8.0.26, 8.0.25, 8.0.24, 8.0.23, 8.0.22, 8.0.21 ...
7.4: 7.4.33, 7.4.32, 7.4.30, 7.4.29, 7.4.28, 7.4.27, 7.4.26, 7.4.25 ...
7.3: 7.3.33, 7.3.32, 7.3.31, 7.3.30, 7.3.29, 7.3.28, 7.3.27, 7.3.26 ...
7.2: 7.2.34, 7.2.33, 7.2.32, 7.2.31, 7.2.30, 7.2.29, 7.2.28, 7.2.27 ...
7.1: 7.1.33, 7.1.32, 7.1.31, 7.1.30, 7.1.29, 7.1.28, 7.1.27, 7.1.26 ...
7.0: 7.0.33, 7.0.32 ...

To show more minor versions:

$ phpbrew known --more

To update the release info:

$ phpbrew update

To get older versions (less than 5.4)

Please note that we don't guarantee that you can build the php versions that are not supported by offical successfully, please don't fire any issue about the older versions, these issues won't be fixed.

$ phpbrew update --old

To list known older versions (less than 5.4)

$ phpbrew known --old

Starting Building Your Own PHP

Simply build and install PHP with default variant:

$ phpbrew install 5.4.0 +default

Here we suggest default variant set, which includes most commonly used variants, if you need a minimum install, just remove the default variant set.

You can enable parallel compilation by passing -j or --jobs option and the following is an example:

$ phpbrew install -j $(nproc) 5.4.0 +default

With tests:

$ phpbrew install --test 5.4.0

With debug messages:

$ phpbrew -d install --test 5.4.0

To install older versions (less than 5.3):

$ phpbrew install --old 5.2.13

To install the latest patch version of a given release:

$ phpbrew install 5.6

To install a pre-release version:

$ phpbrew install 7.2.0alpha1
$ phpbrew install 7.2.0beta2
$ phpbrew install 7.2.0RC3

To install from a GitHub tag or branch name:

$ phpbrew install github:php/[email protected] as php-7.2.0-dev

To install the next (unstable) version:

$ phpbrew install next as php-7.3.0-dev

Cleaning up build directory

$ phpbrew clean php-5.4.0

Variants

PHPBrew arranges configure options for you, you can simply specify variant name, and phpbrew will detect include paths and build options for configuring.

PHPBrew provides default variants and some virtual variants, to the default variants, which includes the most commonly used variants, to the virtual variants, which defines a variant set, you may use one virtual variant to enable multiple variants at one time.

To check out what is included in these variants, run phpbrew variants to list these variants.

To enable one variant, add a prefix + before the variant name, eg

+mysql

To disable one variant, add a prefix - before the variant name.

-debug

For example, if we want to build PHP with the default options and database supports (mysql, sqlite, postgresql), you may simply run:

$ phpbrew install 5.4.5 +default+dbs

You may also build PHP with extra variants:

$ phpbrew install 5.3.10 +mysql+sqlite+cgi

$ phpbrew install 5.3.10 +mysql+debug+pgsql +apxs2

$ phpbrew install 5.3.10 +pdo +mysql +pgsql +apxs2=/usr/bin/apxs2

To build PHP with pgsql (PostgreSQL) extension:

$ phpbrew install 5.4.1 +pgsql+pdo

Or build pgsql extension with postgresql base dir on Mac OS X:

$ phpbrew install 5.4.1 +pdo+pgsql=/opt/local/lib/postgresql91/bin

The pgsql path is the location of pg_config, you could find pg_config in the /opt/local/lib/postgresql91/bin

To build PHP with neutral compile options, you can specify neutral virtual variant, which means that phpbrew doesn't add any additional compile options including --disable-all. But some options(for example --enable-libxml) are still automatically added to support pear installation. You can build PHP with neutral:

$ phpbrew install 5.4.1 +neutral

For more details, please check out PHPBrew Cookbook.

Extra Configure Options

To pass extra configure arguments, you can do this:

$ phpbrew install 5.3.10 +mysql +sqlite -- \
    --enable-ftp --apxs2=/opt/local/apache2/bin/apxs

Use And Switch

Use (switch version temporarily):

$ phpbrew use 5.4.22

Switch PHP version (switch default version)

$ phpbrew switch 5.4.18

Turn Off:

$ phpbrew off

If you enable apache PHP modules, remember to comment out or remove the settings.

$ sudo vim /etc/httpd/conf/httpd.conf
# LoadModule php5_module        /usr/lib/httpd/modules/libphp5.3.21.so
# LoadModule php5_module        /usr/lib/httpd/modules/libphp5.3.20.so

The Extension Installer

See Extension Installer

Configuring the php.ini for current php version

Simply run:

$ phpbrew config

You may specify the EDITOR environment variable to your favorite editor:

export EDITOR=vim
phpbrew config

Upgrade phpbrew

To upgrade phpbrew, you may simply run the self-update command, this command enables you to install the latest version of master branch from GitHub:

$ phpbrew self-update

The Installed PHP(s)

To list all installed php(s), you could run:

$ phpbrew list

The installed phps are located in ~/.phpbrew/php, for example, php 5.4.20 is located at:

~/.phpbrew/php/5.4.20/bin/php

And you should put your configuration file in:

~/.phpbrew/php/5.4.20/etc/php.ini

Extension configuration files should be put in:

~/.phpbrew/php/5.4.20/var/db
~/.phpbrew/php/5.4.20/var/db/xdebug.ini
~/.phpbrew/php/5.4.20/var/db/apc.ini
~/.phpbrew/php/5.4.20/var/db/memcache.ini
... etc

Quick commands to switch between directories

Switching to PHP build directory

$ phpbrew build-dir

Switching to PHP dist directory

$ phpbrew dist-dir

Switching to PHP etc directory

$ phpbrew etc-dir

Switching to PHP var directory

$ phpbrew var-dir

PHP FPM

phpbrew also provides useful fpm managing sub-commands. to use them, please remember to enable +fpm variant when building your own php.

To setup the system FPM service, type one of commands:

# Typing the following command when systemctl is available in the Linux distribution.
$ phpbrew fpm setup --systemctl

# It is available in the Linux distribution.
$ phpbrew fpm setup --initd

# It is available in the macOS.
$ phpbrew fpm setup --launchctl

To start php-fpm, simply type:

$ phpbrew fpm start

To stop php-fpm, type:

$ phpbrew fpm stop

To show php-fpm modules:

phpbrew fpm module

To test php-fpm config:

phpbrew fpm test

To edit php-fpm config:

phpbrew fpm config

The installed php-fpm is located in ~/.phpbrew/php/php-*/sbin.

The correspond php-fpm.conf is located in ~/.phpbrew/php/php-*/etc/php-fpm.conf.default, you may copy the default config file to the desired location. e.g.,

cp -v ~/.phpbrew/php/php-*/etc/php-fpm.conf.default
    ~/.phpbrew/php/php-*/etc/php-fpm.conf

php-fpm --php-ini {php config file} --fpm-config {fpm config file}

Enabling Version Info Prompt

To add PHP version info in your shell prompt, you can use "PHPBREW_SET_PROMPT=1" variable.

The default is "PHPBREW_SET_PROMPT=0" (disable). To enable it, you can add this line to your ~/.bashrc file and put this line before you source ~/.phpbrew/bashrc.

export PHPBREW_SET_PROMPT=1

To embed version info in your prompt, you can use phpbrew_current_php_version shell function, which is defined in .phpbrew/bashrc. and you can set the version info in your PS1 var. e.g.

PS1=" \$(phpbrew_current_php_version) \$ "

Known Issues

  • For PHP-5.3+ versions, "Building intl 64-bit fails on OS X" https://bugs.php.net/bug.php?id=48795

  • To build PHP with GD extension, you need to specify your libpng dir and libjpeg dir, for example,

    $ phpbrew install php-5.4.10 +default +mysql +intl +gettext +apxs2=/usr/bin/apxs2
    -- --with-libdir=lib/x86_64-linux-gnu
    --with-gd=shared
    --enable-gd-natf
    --with-jpeg-dir=/usr
    --with-png-dir=/usr

Troubleshooting

Please see TroubleShooting

FAQ

Q: How do I have the same version with different compile option?

A: Currently, you can install php-5.x.x and rename the /Users/phpbrew/.phpbrew/php/php-5.x.x folder to the new name, for example, php-5.x.x-super , and install another php-5.x.x

Contribution

Please see Contribution

Documentation

Please see Wiki

Founder and Contributors

only listing 1k+ lines contributors, names are sorted in alphabetical order

  • @c9s
  • @GM-Alex
  • @jhdxr
  • @marcioAlmada
  • @morozov
  • @markwu
  • @peter279k
  • @racklin
  • @shinnya

License

See LICENSE file.

onion's People

Contributors

c9s avatar harikt avatar jaceju avatar marcioalmada avatar matteosister avatar nelsonsar avatar yuya-takeyama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onion's Issues

Featured Request : A dot in package name

Hi ,

Nice work . @auraphp would like to use it for creating packages for Aura . But a dot in the package name gives some errors.

Error: Channel validator error: field "name" - package name "Aura.Di" is invalid
Parsing of package.xml from file "package.xml" failed
Cannot package, errors in package file
Done.

Example : package.ini

[package]
name = Aura.Di
desc = package description
version = 0.0.1
channel = pear.php.net
author = Hari K T <[email protected]>

We will be happy if you can make a fix for it .

Also please note that @pyrus already have allowed dot in package name as per the request by @pmjones . See pyrus/Pyrus#75 and pyrus/Pyrus#80

Improve test coverage and test methods name

Some of components are not completely tested and some tests methods have name like "test1". Would awesome if test methods name were more verbose, I mean that it tells to the programmer what is tested on that test.

Package installation from official PEAR channel

Hi.
How can I install packages in official PEAR channel like File_Util or Console_Getopt?

Installation with this package.ini could not work.

[require]
php = 5.2
pearinstaller = 1.4
pear.php.net/Console_Getopt = 1.3.1
pear.php.net/File_Util = 1.0.0

Result is below.

$ ./onion -d bundle
Reading config file: package.ini
        * summary is not defined., use the first paragraph from description by default.
        * license is not defined., use PHP license by default.
Configuring dependencies...
        Tracking dependency for PEAR package: Console_Getopt ...
PHP Fatal error:  Call to a member function getElementsByTagName() on a non-object in phar:///home/yuya/dev/php/phync/onion/Onion/Pear/Channel.php on line 2
PHP Stack trace:
PHP   1. {main}() /home/yuya/dev/php/phync/onion:0
PHP   2. require() /home/yuya/dev/php/phync/onion:6
PHP   3. CLIFramework\Application->run() phar:///home/yuya/dev/php/phync/onion/scripts/onion.embed:2
PHP   4. CLIFramework\CommandBase->executeWrapper() phar:///home/yuya/dev/php/phync/onion/CLIFramework/Application.php:2
PHP   5. call_user_func_array() phar:///home/yuya/dev/php/phync/onion/CLIFramework/CommandBase.php:2
PHP   6. Onion\Command\BundleCommand->execute() phar:///home/yuya/dev/php/phync/onion/CLIFramework/CommandBase.php:2
PHP   7. Onion\Dependency\DependencyResolver->resolve() phar:///home/yuya/dev/php/phync/onion/Onion/Command/BundleCommand.php:2
PHP   8. Onion\Pear\Channel->prefetchPackagesInfo() phar:///home/yuya/dev/php/phync/onion/Onion/Dependency/DependencyResolver.php:2

Fatal error: Call to a member function getElementsByTagName() on a non-object in phar:///home/yuya/dev/php/phync/onion/Onion/Pear/Channel.php on line 2

Call Stack:
    0.0022     625984   1. {main}() /home/yuya/dev/php/phync/onion:0
    0.0063     743896   2. require('phar:///home/yuya/dev/php/phync/onion/scripts/onion.embed') /home/yuya/dev/php/phync/onion:6
    0.0183    1192120   3. CLIFramework\Application->run() phar:///home/yuya/dev/php/phync/onion/scripts/onion.embed:2
    0.0362    1707024   4. CLIFramework\CommandBase->executeWrapper() phar:///home/yuya/dev/php/phync/onion/CLIFramework/Application.php:2
    0.0363    1709248   5. call_user_func_array() phar:///home/yuya/dev/php/phync/onion/CLIFramework/CommandBase.php:2
    0.0364    1709496   6. Onion\Command\BundleCommand->execute() phar:///home/yuya/dev/php/phync/onion/CLIFramework/CommandBase.php:2
    0.0500    1956432   7. Onion\Dependency\DependencyResolver->resolve() phar:///home/yuya/dev/php/phync/onion/Onion/Command/BundleCommand.php:2
    0.0588    2178376   8. Onion\Pear\Channel->prefetchPackagesInfo() phar:///home/yuya/dev/php/phync/onion/Onion/Dependency/DependencyResolver.php:2

Install dependency failed when library does not exists.

package.ini 中加入:

[require]
pear.jaceju.net/Test

pear.jaceju.net/Test 不存在時,會出現以下錯誤:

PHP Fatal error:  Call to a member function getId() on a non-object in phar:///path/to/onion/Onion/Dependency/DependencyPool.php on line 2

建議當套件不存在時,能出現錯誤提示訊息,並提供繼續安裝之選項。

baseinstalldir attribute support

baseinstalldir attribute support:

31  <contents>
32   <dir name="/">
33    <file baseinstalldir="symfony" install-as="helper/TagHelper.php" md5sum="662604c83754a639b5c70002487d23b0" name="lib/helper/TagHelper.php" role="php" />
34    <file baseinstalldir="symfony" install-as="helper/PartialHelper.php" md5sum="baaa96de9c2590e09cfdb4b5fe523981" name="lib/helper/PartialHelper.php" role="php" />
35    <file baseinstalldir="symfony" install-as="helper/DateHelper.php" md5sum="adc48afe25f1baa58e2f0818e7adb977" name="lib/helper/DateHelper.php" role="php" />

error for "self-update" command in a folder with spaces

I keep all my php executables in an Ubuntu One folder (for sharing across my computers), and the Ubuntu One folder has a space in it. I found that the self-update command fails due to a problem with curl....for example, in my environment the command become:

$ curl -# -L https://raw.github.com/c9s/Onion/master/onion > /home/matteo/Ubuntu One/dotfiles/bin/onion

so curl complains:

$ curl: (6) Couldn't resolve host 'One'

I found a quick solution that simply escape the spaces in the script path. You can find it here

If you want a PR it's ready...

Pyrus breaks when installing packages built with Onion

Onion generates package.xml files specifing version="2.0" and using the XSD of package-2.0. The problem is that the install-as attribute used by Onion in file elements is not allowed in this version and Pyrus, which performs XML validation using the XSD, refuses to install our packages lamenting that the XML in package.xml is malformed.

Instead of the install-as attribute in file elements, it would be probably better to use the phprelease node e.g.:

<phprelease>
    <filelist>
        <install name="Predis/Client.php" as="Predis/Client.php" />
        <!-- rest of the list -->
    <filelist>
</phprelease>

Redeclaring custom roles duplicates files on package.xml

At Respect\Foundation, we're building an automated package.ini generator that gathers information from folder structure, git and other files.

From this info, we infer the PHP roles from the directories. For example, if the user has the "lib" folder, its automatically added to the php role. Same happends for the "src" folder and others.

Seems that re-declaring default roles leads to duplication of file tags in the generated package.xml. Other default roles has the same problems, such as "tests".

I've added defensive code on my own project to prevent this and lost my samples, but I can simulate the problem and submit a test case if you need.

Catch package not found exceptions when running bundle command

PHP Notice:  Undefined index: CascadingAttribute in phar:///opt/local/bin/onion.phar/Onion/Pear/Channel.php on line 2
PHP Stack trace:
PHP   1. {main}() /opt/local/bin/onion.phar:0
PHP   2. require() /opt/local/bin/onion.phar:6
PHP   3. CLIFramework\Application->run() phar:///opt/local/bin/onion.phar/scripts/onion.embed:2
PHP   4. Onion\Command\BundleCommand->execute() phar:///opt/local/bin/onion.phar/CLIFramework/Application.php:2
PHP   5. Onion\Dependency\DependencyResolver->resolve() phar:///opt/local/bin/onion.phar/Onion/Command/BundleCommand.php:2
PHP   6. Onion\Pear\Channel->getPackage() phar:///opt/local/bin/onion.phar/Onion/Dependency/DependencyResolver.php:2

Notice: Undefined index: CascadingAttribute in phar:///opt/local/bin/onion.phar/Onion/Pear/Channel.php on line 2

Errors on tests

When you run Onion test you get, for example:
Undefined property: tests\Onion\Dependency\DependencyResolverTest::$logger

Because some tests use $logger as a static variable but it is not. So we have two approaches:

  1. Use mocked instances of logger;
  2. Creating an instance of logger to each test;

Custom structure does not work

We use in our projects mainly the library instead of src as the container for the source code, I tried many variations of the configuration, using roles, modifying the structure and nothing seemed to work.

Am I missing something?

[package]
name = Respect\Validation
desc = The most awesome validation engine ever created for PHP
homepage = http://respect.li
version = 1.0.0
channel = respect.li/pear
repository = github.com/Respect/Validation
authors[] = Alexandre Gaigalas <[email protected]>
authors[] = Augusto Pascutti <[email protected]>
authors[] = Henrique Moody <[email protected]>

[structure]
src  = library

[requires]
php = '>= 5.3.5'
extensions[] = 'reflection'
extensions[] = 'ctype'
extensions[] = 'pcre'

pear.corneltek.com is down

It's not possible to pull down the dependencies for the project at the minute because the pear channel is down.

pear installation failed

The Onion installation via the pear channel failed:

$ pear install corneltek/Onion-alpha
corneltek/Onion requires PHP extension "reflection" (version >= 0), installed version is $Revision: 313665 $
No valid packages found
install failed

I'm using PHP 5.3.8 w/ Reflection compiled in:

$ php -m | grep -i reflec
Reflection

Looks like the module check is case sensitive.

Onion.phar

Hi @c9s ,

I guess the onion.phar got corrupted . Please check .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.