{"id":13462504,"url":"https://github.com/phpenv/phpenv","last_synced_at":"2025-05-14T11:09:02.084Z","repository":{"id":3114123,"uuid":"4140723","full_name":"phpenv/phpenv","owner":"phpenv","description":"Simple PHP version management","archived":false,"fork":false,"pushed_at":"2025-04-29T13:00:57.000Z","size":281,"stargazers_count":1695,"open_issues_count":9,"forks_count":147,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-05-10T08:31:52.840Z","etag":null,"topics":["hacktoberfest","php","tools"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["madumlao"],"liberapay":"phpenv"}},"created_at":"2012-04-25T19:52:16.000Z","updated_at":"2025-05-09T05:47:21.000Z","dependencies_parsed_at":"2025-02-15T10:01:08.472Z","dependency_job_id":"a4d70680-fef8-4c71-8b31-63752f2272c0","html_url":"https://github.com/phpenv/phpenv","commit_stats":{"total_commits":290,"total_committers":14,"mean_commits":"20.714285714285715","dds":0.3620689655172413,"last_synced_commit":"4a14d589fc573f96ecb7edadf77b45c77b0d77e5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpenv%2Fphpenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpenv%2Fphpenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpenv%2Fphpenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpenv%2Fphpenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpenv","download_url":"https://codeload.github.com/phpenv/phpenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129488,"owners_count":22019628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","php","tools"],"created_at":"2024-07-31T12:00:50.007Z","updated_at":"2025-05-14T11:09:02.026Z","avatar_url":"https://github.com/phpenv.png","language":"Shell","funding_links":["https://github.com/sponsors/madumlao","https://liberapay.com/phpenv"],"categories":["Uncategorized","Shell","List of \\*env-, ch\\*- and \\*vm- style version managers","Version Managers"],"sub_categories":["Uncategorized","PHP"],"readme":"## phpenv - PHP multi-version installation and management for humans.\n\n### Key features:\n\nMy name is phpenv. I was designed for humans, to help simplify the management\nof multiple PHP custom build installations.\n\nI was originally inspired by the outstanding work of\n[rbenv][rbenv-url] and [ruby-build][ruby-build-url]\nwith a whole bunch of PHP centric additions\nto help you build your first release, simplify managing and working\nwith diffirent releases and keep you building new release after new\nrelease like there's nothing to it.\n\nYou are a PHP developer, like we are, and you not only have to have the\nlatest and freshest interpreter to spin your scripts but you also care to\nsee what how they get treated when submitted to older interpretations.\nEver wondered why you can't run a PHP app on your own development machine? Well\nyou just found the answer doing when taken for a ride building PHP\non their dev machines. Easily customize your configuration options and even\nbuild pecl extensions into PHP or manually afterwards. Configure and install\ncustom builds of the same PHP release version directly from the PHP source\ncode repository kept in your local `.phpenv` folder.\n\n## How It Works\n\nAfter phpenv injects itself into your PATH at installation time, any invocation\nof `php`, `php-fpm`, or other PHP-related executable will first activate phpenv.\nThen, phpenv scans the current project directory for a file named `.php-version`.\nIf found, that file determines the version of PHP that should be used within that\ndirectory. phpenv then looks up that PHP version among those installed under\n`~/.phpenv/versions/`.\n\nphpenv expects each version to be a directory resulting from a PHP installation.\nThis means each directory has its own binaries, libraries, config files, man pages.\nFor example, each version has its own `php`, `php-fpm`, `pecl`, `pyrus`, `php.ini`.\nphpenv detects which version to run for your project then calls the appropriate file.\n\nYou can choose the PHP version for your project with, for example:\n\n```sh\ncd Projects/my-php-project\n# choose PHP 8.3.13\nphpenv local 8.3.13\n```\n\nDoing so will update the `.php-version` file in the current directory with the\nversion that you've chosen. A different project of yours that is another directory\nmight be using a different version of PHP altogether - phpenv will seamlessly\ntransition from one PHP version to another when you cd into the project directory.\n\nFinally, almost every aspect of phpenv's mechanism is customizable via plugins\nwritten in bash.\n\n## Installation\n\n### Basic GitHub Checkout\nFor a more automated install, you can use [phpenv-installer][phpenv-installer-url].\nIf you prefer a manual approach, follow the steps below.\n\nThis will get you going with the latest version of phpenv and make it\neasy to fork and contribute any changes back upstream.\n\n1. Check out phpenv into `~/.phpenv`.\n\n   ```sh\n   git clone https://github.com/phpenv/phpenv.git ~/.phpenv\n   ```\n\n2. Add `~/.phpenv/bin` to your `$PATH` for access to the `phpenv`\n   command-line utility.\n   \n   The `$PATH` variable is typically set in your shell initialization file.\n   Common examples:\n   - if you are using bash, check if `~/.bash_profile` exists.\n   - if you are using another shell, check your specific shell configuration.\n   - if the above do not exist, shells will typically default to `~/.profile`\n\n   Assuming that your shell initialization is in `~/.profile`, then\n\n   ```sh\n   echo 'export PATH=\"$HOME/.phpenv/bin:$PATH\"' \u003e\u003e ~/.profile\n   ```\n\n3. Add phpenv init to your shell to enable shims and autocompletion.\n\n   ```sh\n   echo 'eval \"$(phpenv init -)\"' \u003e\u003e ~/.profile\n   ```\n\n4. Restart your shell so the path changes take effect. You can now\n   begin using phpenv.\n\n   ```sh\n   exec $SHELL -l\n   ```\n\n5. (Optional) Install php-build into it and any php. (See [php-build][php-build-url] home)\n\n   ```sh\n   git clone https://github.com/php-build/php-build $(phpenv root)/plugins/php-build\n   phpenv install \u003cphp-version\u003e\n   ```\n\n6. (Optional) Rebuild the shim binaries. You should do this any time you install\n   a new PHP binary.\n\n   ```sh\n   phpenv rehash\n   ```\n\n### Upgrading\n\nIf you've installed phpenv using the instructions above, you can\nupgrade your installation at any time using git.\n\nTo upgrade to the latest development version of phpenv, use `git pull`:\n\n```sh\ncd ~/.phpenv \u0026\u0026 git pull\n```\n\n### php-build configuration\nBy default, php-build will compile PHP with a default set of options specified by:\n - php-build [default configure options][php-build-default-configure-opts-url]\n - per-version configure options in the PHP build definition. For example, in [7.4.13](https://github.com/php-build/php-build/blob/master/share/php-build/definitions/7.4.13)\n - configure options specified in environment variables. See [the man page](https://github.com/php-build/php-build/blob/master/man/php-build.1.ronn) for details.\n\nTypically, if you need to specify how PHP is built on your system, you can add configure options in the `PHP_BUILD_CONFIGURE_OPTS` variable, and add PHP extensions in the `PHP_BUILD_INSTALL_EXTENSION` variable.\n\n### Webserver Setup\n#### PHP-FPM\nThe preferred way of connecting phpenv applications is by using php-fpm after building php. Your webserver can then be configured to connect to the php-fpm instance. In this approach, php will run as the permissions of the invoking user, which is not necessarily as the web server.\n\nphp-fpm can be started in one of the following ways:\n - using an init script: by running `~/.phpenv/versions/$VERSION/etc/init.d/php-fpm`\n - using systemd: by installing `~/.phpenv/versions/$VERSION/etc/systemd/system/php-fpm.service`\n - using an init script: by writing your own custom init script\n - using systemd: by writing your own custom systemd unit\n - manually: by running `php-fpm (8)` and supplying command-line arguments\n\nBy default, php-fpm comes with a configuration file under `~/.phpenv/versions/$VERSION/etc/php-fpm.conf`, which it will look for when run. This configures php-fpm to listen on `localhost:9000` when started. You may edit or replace this file, or supply a different configuration file using the `--fpm-config` (`-y`) command line argument.\n\nInstructions for connecting different webservers to php-fpm:\n - for Apache, see the [apache wiki article][apache-wiki-phpfpm]\n - for NGINX, see the [nginx wiki article][nginx-wiki-phpfpm]\n\n#### Apache SAPI\nAlternatively, you may still use the Apache php module by configuring [php-build][php-build-url] to build the libphp.so apache extension (directions to follow). libphp.so can then be found by apache under the `~/.phpenv/versions/$VERSION/libexec` folder. This file can be used for Apache's `LoadModule php5_module` directive and requires Apache to restart when changed.\n\n### Neckbeard Configuration\n\nSkip this section unless you must know what every line in your shell\nprofile is doing.\n\n`phpenv init` is the only command that crosses the line of loading\nextra commands into your shell. Here's what `phpenv init` actually does:\n\n1. Sets up your shims path. This is the only requirement for phpenv to\n   function properly. You could also do this by hand by prepending\n   `~/.phpenv/shims` to your `$PATH`.\n\n2. Installs autocompletion. This is entirely optional but pretty\n   useful. Sourcing `~/.phpenv/completions/phpenv.bash` will set that\n   up. There is also a `~/.phpenv/completions/phpenv.zsh` for Zsh\n   users.\n\n3. Rehashes shims. From time to time you'll need to rebuild your\n   shim files. Doing this on init makes sure everything is up to\n   date. You can always run `phpenv rehash` manually.\n\n4. Installs the sh dispatcher. This bit is also optional, but allows\n   phpenv and plugins to change variables in your current shell, making\n   commands like `phpenv shell` possible. The sh dispatcher doesn't do\n   anything crazy like override `cd` or hack your shell prompt, but if\n   for some reason you need `phpenv` to be a real script rather than a\n   shell function, you can safely skip it.\n\nRun `phpenv init -` for yourself to see exactly what happens under the\nhood.\n\n## Usage\n\nLike `git`, the `phpenv` command delegates to subcommands based on its\nfirst argument. The most common subcommands are:\n\n### phpenv help\n\nShow the usage and useful help.  When you are in trouble, do this ;)\n\n```sh\nphpenv help\nphpenv help \u003csubcommand\u003e\n```\n\n### phpenv install\n\n[php-build][php-build-url] is a phpenv-compatible plugin that builds and installs php. To be able to use phpenv install, download and install the php-build plugin as described in step 5. of the install instructions above.\n\nBefore running phpenv install, make sure the development versions needed to build php are installed in your system. In particular, if you want to build the apache extension, make sure that apache2-dev (or your OS's equivalent) is installed.\n\n### phpenv global\n\nSets the global version of PHP to be used in all shells by writing\nthe version name to the `~/.phpenv/version` file. This version can be\noverridden by a per-project `.phpenv-version` file, or by setting the\n`PHPENV_VERSION` environment variable.\n\n```sh\nphpenv global 5.4.0\n```\n\nThe special version name `system` tells phpenv to use the system PHP\n(detected by searching your `$PATH`).\n\nWhen run without a version number, `phpenv global` reports the\ncurrently configured global version.\n\n### phpenv local\n\nSets a local per-project PHP version by writing the version name to\na `.phpenv-version` file in the current directory. This version\noverrides the global, and can be overridden itself by setting the\n`PHPENV_VERSION` environment variable or with the `phpenv shell`\ncommand.\n\n```sh\nphpenv local 5.3.8\n```\n\nWhen run without a version number, `phpenv local` reports the currently\nconfigured local version. You can also unset the local version:\n\n```sh\nphpenv local --unset\n```\n\n### phpenv shell\n\nSets a shell-specific PHP version by setting the `PHPENV_VERSION`\nenvironment variable in your shell. This version overrides both\nproject-specific versions and the global version.\n\n```sh\nphpenv shell 5.3.9\n```\n\nWhen run without a version number, `phpenv shell` reports the current\nvalue of `PHPENV_VERSION`. You can also unset the shell version:\n\n```sh\nphpenv shell --unset\n```\n\nNote that you'll need phpenv's shell integration enabled (step 3 of\nthe installation instructions) in order to use this command. If you\nprefer not to use shell integration, you may simply set the\n`PHPENV_VERSION` variable yourself:\n\n```sh\nexport PHPENV_VERSION=5.3.13\n```\n\n### phpenv versions\n\nLists all PHP versions known to phpenv, and shows an asterisk next to\nthe currently active version.\n\n```sh\n$ phpenv versions\n  5.2.8\n  5.3.13\n* 5.4.0 (set by /YOUR-USERNAME/.phpenv/global)\n```\n\n### phpenv version\n\nDisplays the currently active PHP version, along with information on\nhow it was set.\n\n```sh\n$ phpenv version\n5.4.0 (set by /YOUR-USERNAME/.phpenv/version)\n```\n\n### phpenv rehash\n\nInstalls shims for all PHP binaries known to phpenv (i.e.,\n`~/.phpenv/versions/*/bin/*`). Run this command after you install a new\nversion of PHP.\n\n```sh\nphpenv rehash\n```\n\n### phpenv which\n\nDisplays the full path to the binary that phpenv will execute when you\nrun the given command.\n\n```sh\n$ phpenv which pyrus\n/YOUR-USERNAME/.phpenv/versions/5.4.0/bin/pyrus\n```\n\n## Environment variables\n\nYou can affect how phpenv operates with the following settings:\n\nname | default | description\n-----|---------|------------\n`PHPENV_VERSION`| | Specifies the PHP version to be used.\u003cbr\u003eAlso see [`phpenv shell`](#phpenv-shell)\n`PHPENV_ROOT` | `~/.phpenv` | Defines the directory under which PHP versions and shims reside.\u003cbr\u003eAlso see [`phpenv root`](#phpenv-root)\n`PHPENV_DEBUG` | | Outputs debug information.\u003cbr\u003eAlso as `phpenv --debug \u003csubcommand\u003e`\n`PHPENV_HOOK_PATH` | | Colon-separated list of paths searched for phpenv hooks.\n`PHPENV_DIR` | `$PWD` | Directory to start searching for `.php-version` files.\n\n### Uninstalling phpenv\n\nThe simplicity of phpenv makes it easy to temporarily disable it, or uninstall from the system.\n\n1. To **disable** phpenv managing your PHP versions, simply comment or remove the `phpenv init` line from your shell startup configuration. This will remove phpenv shims directory from PATH, and future invocations like `php` will execute the system PHP version, bypassing phpenv completely.\n\n   While disabled, `phpenv` will still be accessible on the command line, but your PHP projects won't be affected by version switching.\n\n2. To completely **uninstall** phpenv, perform step (1) and then remove the phpenv root directory. This will **delete all PHP versions** that were installd under `` `phpenv root`/versions/ `.\n\n## Development\n\nThe phpenv source code is [hosted on GitHub][phpenv-url]. It's clean, modular,\nand easy to understand (thanks to the rbenv project), even if you're not a\nshell hacker.\n\nTests are executed using [Bats][bats-url]\n\n```sh\nbats test\nbats test/\u003cfile\u003e.bats\n```\n\nThis project is basically a clone (Read: \"search and replace\") of the rbenv\nproject. It's in need of love and support. If you're interested in improving it\nplease feel free to fork, submit [pull requests][phpenv-prs] and file bugs on the [issue\ntracker][phpenv-issues].\n\n\n### License\n\n(The MIT license)\n\nCopyright (c) 2012 Dominic Giglio\\\nCopyright (c) 2013 Nick Lombard\\\nCopyright (c) 2015 madumlao\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[original-url]: https://github.com/phpenv/phpenv\n[php-build-url]: https://github.com/php-build/php-build\n[php-build-default-configure-opts-url]: https://github.com/php-build/php-build/blob/master/share/php-build/default_configure_options\n[phpenv-url]: https://github.com/phpenv/phpenv\n[phpenv-issues]: https://github.com/phpenv/phpenv/issues\n[phpenv-installer-url]: https://github.com/phpenv/phpenv-installer\n[phpenv-prs]: https://github.com/phpenv/phpenv/pulls\n[rbenv-url]: https://github.com/rbenv/rbenv\n[ruby-build-url]: https://github.com/rbenv/ruby-build\n[apache-wiki-phpfpm]: https://wiki.apache.org/httpd/PHP-FPM\n[nginx-wiki-phpfpm]: https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/\n[bats-url]: https://github.com/bats-core/bats-core\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpenv%2Fphpenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpenv%2Fphpenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpenv%2Fphpenv/lists"}