{"id":18737894,"url":"https://github.com/technodelight/shell-exec","last_synced_at":"2025-04-12T19:32:32.473Z","repository":{"id":57066159,"uuid":"138048434","full_name":"technodelight/shell-exec","owner":"technodelight","description":"Assemble commands and execute in shell with PHP easier","archived":false,"fork":false,"pushed_at":"2018-06-20T15:58:39.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T14:05:16.892Z","etag":null,"topics":["command-line","execute","php","shell"],"latest_commit_sha":null,"homepage":null,"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/technodelight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-20T15:01:46.000Z","updated_at":"2021-03-07T17:50:01.000Z","dependencies_parsed_at":"2022-08-24T14:53:59.814Z","dependency_job_id":null,"html_url":"https://github.com/technodelight/shell-exec","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technodelight%2Fshell-exec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technodelight%2Fshell-exec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technodelight%2Fshell-exec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technodelight%2Fshell-exec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technodelight","download_url":"https://codeload.github.com/technodelight/shell-exec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248305839,"owners_count":21081574,"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":["command-line","execute","php","shell"],"created_at":"2024-11-07T15:27:19.485Z","updated_at":"2025-04-12T19:32:32.182Z","avatar_url":"https://github.com/technodelight.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shell-exec\nAssemble commands and execute in shell with PHP easier\n\n# Install\n\nVia composer.\n```\ncomposer require technodelight/shell-exec\n```\n\n# Usage\n\n```php\n\u003c?php\n\nuse Technodelight\\ShellExec\\Command;\nuse Technodelight\\ShellExec\\Exec;\n\n$shell = new Exec('which');\n$output = $shell-\u003eexec(\n    Command::create()\n        -\u003ewithArgument('php')\n        -\u003ewithStdErrToStdOut()\n        -\u003ewithStdOutTo('/dev/null') // command will be assembled as 'which php 2\u003e'\n);\n\nvar_dump($output); // will be [\"/usr/bin/php\"]\n```\nWhen an exception happens, an instance of `ShellCommandException` would be thrown.\n`ShellCommandException` will still have the command result:\n```php\n\u003c?php\n\nuse Technodelight\\ShellExec\\Command;\nuse Technodelight\\ShellExec\\Exec;\nuse Technodelight\\ShellExec\\ShellCommandException;\n\ntry {\n    $shell = new Exec;\n    $shell-\u003eexec(\n        Command::create('which')\n            -\u003ewithArgument('nope') // command will be assembled as 'which nope'\n    );\n} catch(ShellCommandException $e) {\n    // $e-\u003egetCode() will be the shell return code for the executed command.\n    var_dump($e-\u003egetResult());\n}\n```\nThere are multiple drivers available\n\n- `Exec`\n- `Passthru`\n\nAnd a special one:\n\n- `TestShell`, which can be used for behavioural testing. For behat please refer to `ShellExec\\FixtureContext`.\n\n# License\nThe MIT License (MIT)\n\nCopyright (c) 2015-2018 Zsolt Gál\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.⏎","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnodelight%2Fshell-exec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnodelight%2Fshell-exec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnodelight%2Fshell-exec/lists"}