{"id":17347508,"url":"https://github.com/cryptiklemur/environment-php","last_synced_at":"2025-08-17T18:07:46.436Z","repository":{"id":15804357,"uuid":"18543852","full_name":"cryptiklemur/environment-php","owner":"cryptiklemur","description":"Environment Class for PHP","archived":false,"fork":false,"pushed_at":"2020-09-24T19:57:27.000Z","size":27,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-12T15:46:45.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptiklemur.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":"2014-04-08T03:25:44.000Z","updated_at":"2020-09-24T19:57:30.000Z","dependencies_parsed_at":"2022-09-24T04:31:55.151Z","dependency_job_id":null,"html_url":"https://github.com/cryptiklemur/environment-php","commit_stats":null,"previous_names":["cryptiklemur/environment-php","aequasi/environment-php"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/cryptiklemur/environment-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fenvironment-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fenvironment-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fenvironment-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fenvironment-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptiklemur","download_url":"https://codeload.github.com/cryptiklemur/environment-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptiklemur%2Fenvironment-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270885344,"owners_count":24662447,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-15T16:48:59.976Z","updated_at":"2025-08-17T18:07:46.407Z","avatar_url":"https://github.com/cryptiklemur.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Environment\n===========\n\nThis class is pretty simple. It adds environments to your PHP project.\n\n## To Install\n\nInstall with composer:\n\n```sh\ncomposer require aequasi/environment\n```\n\n## To Use\n\nTo get set up, drop the `Environment` class in your front controller. For example:\n\n```php\n\u003c?php\n\nrequire_once __DIR__.'/vendor/autoload.php';\n\n$environment = new Aequasi\\Environment\\Environment;\n\n// By default, the environment is set to 'dev'\necho $environment-\u003egetType();\n// Above will echo 'dev';\nvar_dump($environment-\u003eisDebug());\n// Above will dump true\n```\n\nYou can set what the default environment is with `Environment::$DEFAULT_ENVIRONMENT` (`string`),\nand you can set what environments are in debug mode with `Environment::$DEBUG_TYPES` (`string[]`).\n\nThe allowed environments can also be changed by overriding the `Environment::$DEFAULT_TYPE` (`string[]`) parameter.\n\n### Setting Environments\n\nOnce you are ready to start using other environments (`test`, `staging`, and `prod`), there are a couple ways to do that.\n\n#### 1. `php.ini`\n\nIn your `php.ini` file, setting `php.environment` will set the environment for all processes using the php for that php.ini\n\n#### 2. `$_SERVER['PHP_ENVIRONMENT']`\n\nYou can either use Apache or Nginx to set a server variable, or you can modify your `$_SERVER` header to set the environment\n\n* For Apache, use [`SetEnv`][0]\n* And Nginx is a little different. Check [this][1] StackOverflow post for an example.\n\n#### 3. CLI Arguments\n\nIf you are using the `SymfonyEnvironment` class, you can tie into the arguments (`--env` and `--no-debug`) by creating your environment\na little differently:\n\n```php\n#!/usr/bin/env php\n\u003c?php\nset_time_limit(0);\n\nrequire_once __DIR__.'/bootstrap.php.cache';\nrequire_once __DIR__.'/AppKernel.php';\n\nuse Symfony\\Bundle\\FrameworkBundle\\Console\\Application;\nuse Symfony\\Component\\Console\\Input\\ArgvInput;\nuse Symfony\\Component\\Debug\\Debug;\nuse Aequasi\\Environment\\SymfonyEnvironment;\n\n$input = new ArgvInput( );\n$env = new SymfonyEnvironment( $input );\n\nif( $env-\u003eisDebug() ) {\n  Debug::enable();\n}\n\n$kernel = new AppKernel( $env-\u003egetType(), $env-\u003eisDebug() );\n$application = new Application($kernel);\n$application-\u003erun( $input );\n```\n\n\n[0]: http://httpd.apache.org/docs/2.2/mod/mod_env.html#SetEnv\n[1]: http://stackoverflow.com/a/19491780/248903\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptiklemur%2Fenvironment-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptiklemur%2Fenvironment-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptiklemur%2Fenvironment-php/lists"}