{"id":20004735,"url":"https://github.com/ramsey/composer-repl-lib","last_synced_at":"2026-03-04T06:24:11.111Z","repository":{"id":39532129,"uuid":"449421834","full_name":"ramsey/composer-repl-lib","owner":"ramsey","description":":shell::books: The library behind ramsey/composer-repl, allowing for extension of the ramsey/composer-repl Composer plugin and non-plugin use of the repl command.","archived":false,"fork":false,"pushed_at":"2025-03-06T01:56:36.000Z","size":237,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-25T11:51:33.419Z","etag":null,"topics":["composer-package","composer-plugin","php","psysh","repl","shell"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/ramsey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"ramsey"}},"created_at":"2022-01-18T19:36:06.000Z","updated_at":"2025-03-06T01:56:40.000Z","dependencies_parsed_at":"2025-05-04T17:33:16.944Z","dependency_job_id":"ed63a337-8671-4167-a520-6fc3b3556eef","html_url":"https://github.com/ramsey/composer-repl-lib","commit_stats":{"total_commits":92,"total_committers":2,"mean_commits":46.0,"dds":"0.021739130434782594","last_synced_commit":"d147cc3222c1532b125b81af717c842a846f1a36"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ramsey/composer-repl-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fcomposer-repl-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fcomposer-repl-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fcomposer-repl-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fcomposer-repl-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramsey","download_url":"https://codeload.github.com/ramsey/composer-repl-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fcomposer-repl-lib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262720297,"owners_count":23353418,"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":["composer-package","composer-plugin","php","psysh","repl","shell"],"created_at":"2024-11-13T05:32:41.201Z","updated_at":"2025-07-03T22:33:38.335Z","avatar_url":"https://github.com/ramsey.png","language":"PHP","funding_links":["https://github.com/sponsors/ramsey"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eramsey/composer-repl-lib\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eThe library behind the \u003ca href=\"https://github.com/ramsey/composer-repl\"\u003eramsey/composer-repl\u003c/a\u003e Composer plugin.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/ramsey/composer-repl-lib\"\u003e\u003cimg src=\"http://img.shields.io/badge/source-ramsey/composer--repl--lib-blue.svg?style=flat-square\" alt=\"Source Code\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/ramsey/composer-repl-lib\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/ramsey/composer-repl-lib.svg?style=flat-square\u0026label=release\" alt=\"Download Package\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://php.net\"\u003e\u003cimg src=\"https://img.shields.io/packagist/php-v/ramsey/composer-repl-lib.svg?style=flat-square\u0026colorB=%238892BF\" alt=\"PHP Programming Language\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ramsey/composer-repl-lib/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/ramsey/composer-repl-lib.svg?style=flat-square\u0026colorB=darkcyan\" alt=\"Read License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ramsey/composer-repl-lib/actions/workflows/continuous-integration.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/ramsey/composer-repl-lib/continuous-integration.yml?branch=main\u0026style=flat-square\u0026logo=github\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/ramsey/composer-repl-lib\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/gh/ramsey/composer-repl-lib?label=codecov\u0026logo=codecov\u0026style=flat-square\" alt=\"Codecov Code Coverage\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\nThis is the library that powers the [ramsey/composer-repl](https://github.com/ramsey/composer-repl)\n[Composer](https://getcomposer.org/) plugin. Since you can't extend Composer\nplugins, this exists to allow for extension. This library also allows for\nnon-plugin use of the `repl` CLI tool, which you may use even if you do not wish\nto use the plugin functionality.\n\n\u003e [!TIP]\n\u003e If you don't need to extend this for your own plugin needs, and you want the\n\u003e functionality provided by the plugin, check out\n\u003e [ramsey/composer-repl](https://github.com/ramsey/composer-repl) instead.\n\nREPL stands for *read-eval-print loop*. It's a language shell that reads user\ninput, evaluates the input using a programming language (in this case, PHP), and\nprints the output to the screen. Then, it returns to the read state (that's the\n*loop* part).\n\n[PsySH](https://psysh.org) is the REPL providing the magic behind\nramsey/composer-repl and ramsey/composer-repl-lib. PsySH is a language shell for\nPHP. It's similar to [irb](https://github.com/ruby/irb) for Ruby,\n[IPython](https://ipython.org) for Python, and\n[JShell](https://docs.oracle.com/javase/9/tools/jshell.htm) for Java. In addition\nto acting as a language shell, PsySH can also function as an interactive debugger\nand development console. [Laravel Tinker](https://github.com/laravel/tinker),\n[Drush](https://www.drush.org) for Drupal,\n[WP-CLI shell](https://github.com/wp-cli/shell-command) for WordPress,\n[CakePHP console](https://book.cakephp.org/3/en/console-and-shells/repl.html),\nand [Yii shell](https://github.com/yiisoft/yii2-shell) are a few of the projects\nusing PsySH.\n\nThis project adheres to a [code of conduct](CODE_OF_CONDUCT.md).\nBy participating in this project and its community, you are expected to\nuphold this code.\n\n## Installation\n\nInstall this package as a development dependency using\n[Composer](https://getcomposer.org).\n\n``` bash\ncomposer require --dev ramsey/composer-repl-lib\n```\n\n## Usage\n\nOpen your terminal and type `./vendor/bin/repl`.\n\nYou'll see something similar to this:\n\n```\nPsy Shell v0.12.7 (PHP 8.4.4 — cli) by Justin Hileman\n------------------------------------------------------------------------\nWelcome to the development console (REPL).\nTo learn more about what you can do in PsySH, type `help`.\n------------------------------------------------------------------------\n\u003e\u003e\u003e\n```\n\nWhile in the dev console, you can do cool things like this:\n\n``` php\n\u003e\u003e\u003e $hello = 'Hello, world'\n=\u003e \"Hello, world\"\n\n\u003e\u003e\u003e echo $hello\nHello, world\n\n\u003e\u003e\u003e foreach ([1, 2, 3] as $x) echo $x . \"\\n\"\n1\n2\n3\n\n\u003e\u003e\u003e $date = new DateTimeImmutable();\n=\u003e DateTimeImmutable @1598393282 {#6953\n     date: 2020-08-25 22:08:02.643076 UTC (+00:00),\n   }\n\n\u003e\u003e\u003e $getDate = fn (DateTimeInterface $dt): DateTimeInterface =\u003e $dt;\n=\u003e Closure(DateTimeInterface $dt): DateTimeInterface {#6964 …3}\n\n\u003e\u003e\u003e t assertInstanceOf(DateTimeInterface::class, $date);\nTest passed!\n\n\u003e\u003e\u003e t assertSame($date, $getDate($date))\nTest passed!\n\n\u003e\u003e\u003e phpunit\n\nPHPUnit 11.5.11 by Sebastian Bergmann and contributors.\n\nRuntime:       PHP 8.4.4\nConfiguration: /path/to/ramsey/conventional-commits/phpunit.xml.dist\n\n...............................................................  63 / 221 ( 28%)\n............................................................... 126 / 221 ( 57%)\n............................................................... 189 / 221 ( 85%)\n................................                                221 / 221 (100%)\n\nTime: 00:00.064, Memory: 12.00 MB\n\nOK (221 tests, 484 assertions)\n```\n\n\u003e [!IMPORTANT]\n\u003e ✨🐘 This implementation of PsySH has Super ElePHPant Powers. 🐘✨\n\n## Environment Bootstrapping\n\nThe power of this REPL comes in its ability to act as a tool in your local\ndevelopment environment. So, you might want to load parts of your environment\n(i.e., configuration, objects, etc.), so you can access these from within the\nREPL.\n\nYou can do this by specifying any number of PHP scripts to include in\n`composer.json`, like this:\n\n``` json\n{\n    \"extra\": {\n        \"ramsey/composer-repl\": {\n            \"includes\": [\n                \"repl.php\",\n                \"tests/bootstrap.php\"\n            ]\n        }\n    }\n}\n```\n\nAny variables set or configuration loaded from these scripts is available to use\nfrom within the REPL.\n\nFor example, if `repl.php` contains:\n\n``` php\n\u003c?php\n$foo = 'bar';\n```\n\nAnd we use `composer.json` to load it with the REPL:\n\n``` json\n{\n    \"extra\": {\n        \"ramsey/composer-repl\": {\n            \"includes\": [ \"repl.php\" ]\n        }\n    }\n}\n```\n\nThen, when we're in the REPL, we'll see `$foo` defined:\n\n```\n\u003e\u003e\u003e ls\nVariables: $env, $foo, $phpunit\n\n\u003e\u003e\u003e $foo\n=\u003e \"bar\"\n```\n\n## Contributing\n\nContributions are welcome! To contribute, please familiarize yourself with\n[CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Coordinated Disclosure\n\nKeeping user information safe and secure is a top priority, and we welcome the\ncontribution of external security researchers. If you believe you've found a\nsecurity issue in software that is maintained in this repository, please read\n[SECURITY.md](SECURITY.md) for instructions on submitting a vulnerability report.\n\n## Copyright and License\n\nThe ramsey/composer-repl-lib library is copyright © [Ben Ramsey](https://benramsey.com)\nand licensed for use under the terms of the\nMIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framsey%2Fcomposer-repl-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framsey%2Fcomposer-repl-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framsey%2Fcomposer-repl-lib/lists"}