{"id":15917537,"url":"https://github.com/takuya/php-shell","last_synced_at":"2025-06-28T02:33:40.219Z","repository":{"id":57064700,"uuid":"255992345","full_name":"takuya/php-shell","owner":"takuya","description":"php safer shell execution","archived":false,"fork":false,"pushed_at":"2020-04-16T14:28:03.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T01:14:05.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takuya.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":"2020-04-15T17:40:14.000Z","updated_at":"2020-04-16T13:57:48.000Z","dependencies_parsed_at":"2022-08-24T14:01:13.722Z","dependency_job_id":null,"html_url":"https://github.com/takuya/php-shell","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takuya%2Fphp-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takuya","download_url":"https://codeload.github.com/takuya/php-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246998102,"owners_count":20866690,"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":[],"created_at":"2024-10-06T18:11:18.156Z","updated_at":"2025-04-03T11:41:55.503Z","avatar_url":"https://github.com/takuya.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Examples \n```php\n$name = \"takuya\";\n$ret = PHPShell::exec_command('echo $name', ['name'=\u003e$name]);\n```\nApparently, `$name` in `'echo $name` looks like php variable, but `$name` is as passed shell env variable.\n\n# Compare to escapeshellarg\n\nQuart is unfriendly for debugging. \n```php\n$name = \"takuy'a;curl -h \";\n$name = escapeshellarg($name); // -\u003e \"'takuy'\\''a;curl -h '\" \n```\n\nLong string arguments make code more difficult to read..\n```php\n$url =  escapeshellarg(\"too long argument ..afasdfasdfasdfasdfawefadf\");\n$json = escapeshellarg(json_encode($object))\n$cmd = 'curl -v -L $url -X POST --data $json';\nvar_dump($cmd);\n```\n\nUsing Environment is more simple. And become more clear code what we will do.  \n```php\n$env_vars =  ['url'=\u003e$url, 'json'=\u003e$json];\nforeach( $env_vars as $k=\u003e$v ){\n  putenv(\"$k=$v\");\n}\n$ret = shell_exec('curl -v -L $url -X POST --data $json');\n```\n\nFor this reason, this library supports you to pass argument as Environment instead of raw string.\n\n# Feature\nSafer calling Shell Command.  To avoid escaping Shell arguments , this library using ENV.\nBy using Env instead of escaping, shell command call become slightly safer and simpler to avoid shell command injection. \n\n\n# since \n- First release was 2008.\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakuya%2Fphp-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakuya%2Fphp-shell/lists"}