{"id":14966804,"url":"https://github.com/timkelty/craftcms-bootstrap","last_synced_at":"2025-10-25T17:30:44.443Z","repository":{"id":62508220,"uuid":"122968712","full_name":"timkelty/craftcms-bootstrap","owner":"timkelty","description":"Streamline Craft CMS bootstrapping and configuration.","archived":false,"fork":false,"pushed_at":"2018-06-25T16:50:54.000Z","size":673,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T09:34:19.419Z","etag":null,"topics":["craft3","craftcms","dotenv"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timkelty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-26T12:45:13.000Z","updated_at":"2018-10-04T01:50:59.000Z","dependencies_parsed_at":"2022-11-02T10:30:45.544Z","dependency_job_id":null,"html_url":"https://github.com/timkelty/craftcms-bootstrap","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timkelty%2Fcraftcms-bootstrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timkelty%2Fcraftcms-bootstrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timkelty%2Fcraftcms-bootstrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timkelty%2Fcraftcms-bootstrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timkelty","download_url":"https://codeload.github.com/timkelty/craftcms-bootstrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238183723,"owners_count":19430175,"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":["craft3","craftcms","dotenv"],"created_at":"2024-09-24T13:36:58.393Z","updated_at":"2025-10-25T17:30:39.047Z","avatar_url":"https://github.com/timkelty.png","language":"PHP","readme":"# Craft CMS Bootstrap\n\n![Boot by Ben Davis from the Noun Project](resources/boot-logo.svg)\n\n## What it does\n\nReduces boilerplate for bootstrapping and configuration by abstracting common tasks to a simple api.\nUsed by [Fusionary's Craft CMS Boilerplate](https://github.com/timkelty/craftcms-boilerplate).\n \n### Bootstrap\n\n\u003e e.g `@webroot/index.php`\n\n- Reduces your app bootstrap boilerplate code to a single chainable statement.\n  - This is especially helpful for achieving consistency when dealing with multiple access points (e.g. [multi-site](https://craftcms.com/news/craft-3-multi-site), [console app](https://craftcms.com/classreference/etc/console/ConsoleApp))\n- Sets [PHP constants](https://github.com/craftcms/docs/blob/v3/en/configuration.md#php-constants), with sensible fallbacks.\n- Gracefully loads .env file environment variables.\n\n### Configuration files\n\n\u003e e.g. `@root/config/general.php` or any [configuration files](https://docs.craftcms.com/api/v3/craft-config-generalconfig.html#properties)\n\n- Retrieves environment variables with fallbacks and [content-aware type conversion](https://github.com/jpcercal/environment#examples). For example:\n  - `export MY_BOOL=true` → `bool`\n  - `export MY_INT=3` → `int`\n- Provides access to HTTP request headers (via `yii\\web\\Request`), should your configuration rely on it.\n- Provides method to map your entire config to any matching/prefixed environment variables.\n  - For example, `$config['allowAutoUpdates']` will match `CRAFT_ALLOW_AUTO_UPDATES` from environment\n\n## Prerequisites\n\n```\n\"php\": \"\u003e=7.1.0\",\n\"craftcms/cms\": \"^3.0.0-RC1\",\n```\n\n## Installation\n\n```\ncomposer require fusionary/craftcms-bootstrap\n```\n\n## API Documentation\n[Class Reference / API Documentation](http://htmlpreview.github.io/?https://github.com/timkelty/craftcms-bootstrap/blob/master/docs/api/fusionary-craftcms-bootstrap-bootstrap.html)\n\n## Examples\n\n### Web app\n\n\u003e e.g. `@root/public/index.php`\n\n```php\n\u003c?php\nrequire_once dirname(__DIR__) . '/vendor/autoload.php';\nfusionary\\craftcms\\bootstrap\\Bootstrap::run();\n```\n\n### Multi-site web app\n\n\u003e e.g. `@root/public/site-handle/index.php`\n\n```php\n\u003c?php\nrequire_once dirname(__DIR__, 2) . '/vendor/autoload.php';\nfusionary\\craftcms\\bootstrap\\Bootstrap\n    -\u003esetDepth(2) // Set the depth of this script from your project root (`CRAFT_BASE_PATH`) to determine paths\n    -\u003esetSite('site-handle') // If the containing folder matches the site handle, you could dynamically set this with `basename(__DIR__)`\n    -\u003erun();\n```\n\n### Console app\n\n\u003e e.g. `@root/craft`\n\n```php\n\u003c?php\nrequire_once dirname(__DIR__) . '/vendor/autoload.php';\nexit(Bootstrap::run('console')-\u003esetDepth(0)-\u003erun()); // Override the default depth of 1, since this script is in `@root`.\n```\n\n### Environment variable mapping\n\nPassing your config through `Config::mapMultiEnvConfig` or `Config::mapConfig`\nwill map all settings to corresponding environment variables (if they exist).\n\nSettings are converted from their Craft/PHP versions (camel-case) to their environment variable versions (all-caps, snake-case, prefixed — e.g. **CRAFT_**, **DB_**).\n\n#### General config\n\n\u003e e.g. @root/config/general.php\n\n```php\n\u003c?php\n// Example environment:\n// export CRAFT_ALLOW_AUTO_UPDATES=true;\n\nuse fusionary\\craftcms\\bootstrap\\helpers\\Config;\n\nreturn Config::mapMultiEnvConfig([\n    '*' =\u003e [\n        'allowAutoUpdates' =\u003e true,\n        'someOtherSetting' =\u003e 'foo',\n\n        // Example: get HTTP header from request\n        'devServerProxy' =\u003e Config::getHeader('x-dev-server-proxy') ?? false,\n    ],\n    'production' =\u003e [\n        'allowAutoUpdates' =\u003e false,\n    ]\n]);\n\n// Result:\n// return [\n//  '*' =\u003e [\n//    'allowAutoUpdates' =\u003e true,\n//    'someOtherSetting' =\u003e 'foo'\n//  ],\n//  'production' =\u003e [\n//    'allowAutoUpdates' =\u003e true\n//  ]\n// ];\n```\n\n#### Database config\n\n\u003e e.g. @root/config/db.php\n\n```php\n\u003c?php\n// Example environment:\n// export DB_DRIVER=mysql\n// export DB_SERVER=mysql\n// export DB_USER=my_app_user\n// export DB_PASSWORD=secret\n// export DB_DATABASE=my_app_production\n// export DB_SCHEMA=public\n\nuse fusionary\\craftcms\\bootstrap\\helpers\\Config;\n\n// Pass prefix as 2nd argument, defaults to 'CRAFT_'\nreturn Config::mapConfig([\n  'driver' =\u003e null,\n  'server' =\u003e null,\n  'user' =\u003e null,\n  'password' =\u003e null,\n  'database' =\u003e null,\n  'schema' =\u003e null,\n], 'DB_');\n\n// Result:\n// return [\n//   'driver' =\u003e 'mysql',\n//   'server' =\u003e 'mysql',\n//   'user' =\u003e 'my_app_user',\n//   'password' =\u003e 'secret',\n//   'database' =\u003e 'my_app_production',\n//   'schema' =\u003e 'public',\n// ]\n```\n\n## Generate documentation\n\n```\ncomposer run-script build-docs\n```\n\n## Acknowledgements\n\n\"[Boot](https://thenounproject.com/term/boot/1466612/)\" icon by Ben Davis from [The Noun Project](https://thenounproject.com/)\n","funding_links":[],"categories":["Resources"],"sub_categories":["Dev Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimkelty%2Fcraftcms-bootstrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimkelty%2Fcraftcms-bootstrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimkelty%2Fcraftcms-bootstrap/lists"}