{
    "url": "https://delaparra-services.nl/skills/laravel-env-config",
    "locale": "en",
    "title": "Laravel environment and config | DeLaParra Services",
    "description": "Use when working with environment variables, .env files and configuration in a Laravel app - adding a new setting, APP_KEY, database/mail/queue credentials, config caching, secrets in CI/CD or Docker, or debugging \"env() returns null in production\". Keeps secrets out of Git and config reads cache-safe.",
    "alternates": {
        "en": "https://delaparra-services.nl/skills/laravel-env-config",
        "nl": "https://delaparra-services.nl/nl/skills/laravel-env-config"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/skills/laravel-env-config.csv",
        "md": "https://delaparra-services.nl/skills/laravel-env-config.md",
        "json": "https://delaparra-services.nl/skills/laravel-env-config.json",
        "zip": "https://delaparra-services.nl/skills/laravel-env-config.zip",
        "pdf": "https://delaparra-services.nl/skills/laravel-env-config.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/skills/laravel-env-config.csv",
            "encodingFormat": "text/csv",
            "name": "laravel-env-config.csv"
        },
        {
            "url": "https://delaparra-services.nl/skills/laravel-env-config.json",
            "encodingFormat": "application/json",
            "name": "laravel-env-config.json"
        },
        {
            "url": "https://delaparra-services.nl/skills/laravel-env-config.md",
            "encodingFormat": "text/markdown",
            "name": "laravel-env-config.md"
        },
        {
            "url": "https://delaparra-services.nl/skills/laravel-env-config.pdf",
            "encodingFormat": "application/pdf",
            "name": "laravel-env-config.pdf"
        },
        {
            "url": "https://delaparra-services.nl/skills/laravel-env-config.zip",
            "encodingFormat": "application/zip",
            "name": "laravel-env-config.zip"
        },
        {
            "url": "https://delaparra-services.nl/skills/laravel-env-config/download",
            "encodingFormat": "application/zip",
            "name": "laravel-env-config-files.zip"
        }
    ],
    "markdown": "# Laravel environment and config\n\n \n\nUse when working with environment variables, .env files and configuration in a Laravel app - adding a new setting, APP\\_KEY, database/mail/queue credentials, config caching, secrets in CI/CD or Docker, or debugging \"env() returns null in production\". Keeps secrets out of Git and config reads cache-safe.\n\n \n\n**Licence** MIT\n\n \n\n**Source** delaparra-original\n\n [Download zip](<https://delaparra-services.nl/skills/laravel-env-config/download>)   \n\n# Laravel environment and config\n\n \n\nSettings that differ per environment (local, staging, production) or that are secret live in ` .env `. Code reads them through ` config() `, never directly through ` env() `.\n\n \n\n## Rules\n\n \n\n1. **` .env ` is never committed.** It must be in ` .gitignore `. Commit ` .env.example ` with every key and safe placeholder values. \n1. **Only call ` env() ` inside ` config/*.php ` files.** Everywhere else use ` config('services.mollie.key') `. After ` php artisan config:cache ` (which production should run), ` env() ` returns ` null ` outside config files. \n1. **Every new variable is added in three places:** ` .env.example ` (placeholder), the relevant ` config/*.php ` file (with a sensible default), and the deployment's secret store (server ` .env `, Forge/Cloud environment, GitHub Actions secrets, Docker secrets). \n1. **Never log or print secrets.** Don't put them in exceptions, ` dd() `, or error pages. Production must have ` APP_DEBUG=false `. \n1. **APP\\_KEY** is generated once per environment with ` php artisan key:generate ` and must never change on a live app (it breaks encrypted data and sessions). Don't share it between environments.\n\n \n\n## Adding a setting: example\n\n \n\n` .env.example `\n\n \n\n```\nMOLLIE_KEY=\n```\n\n \n\n` config/services.php `\n\n \n\n```\n'mollie' => [\n    'key' => env('MOLLIE_KEY'),\n],\n```\n\n \n\nUsage\n\n \n\n```\n$key = config('services.mollie.key');\n```\n\n \n\n## Common keys to check\n\n \n\n` APP_ENV `, ` APP_DEBUG `, ` APP_URL ` (wrong value breaks links, Vite and signed URLs), ` DB_* `, ` CACHE_STORE `, ` QUEUE_CONNECTION `, ` SESSION_DRIVER `, ` SESSION_DOMAIN `, ` SESSION_SECURE_COOKIE `, ` MAIL_* `, ` LOG_CHANNEL `.\n\n \n\n## Changing config in production\n\n \n\n```\nphp artisan config:clear   # after editing .env on the server\nphp artisan config:cache   # rebuild cache\nphp artisan queue:restart  # workers keep old config until restarted\n```\n\n \n\n## Docker and CI\n\n \n\n- Docker Compose: ` env_file: .env ` or ` environment: `; don't bake secrets into images with ` ENV ` or ` ARG `. \n- CI (GitHub Actions): store values as repository/environment secrets and write them at runtime; for tests use ` .env.testing ` or ` phpunit.xml ` ` <env> ` entries with fake values.\n\n \n\n## If a secret was committed\n\n \n\nTreat it as leaked: rotate the key at the provider first, then remove it from the repo. Removing it from history alone is not enough.\n\n \n\n## Files\n\n \n\n- ` LICENSE ` \n- ` SKILL.md ` \n- ` SOURCE.md `\n\n \n\n## Related terms\n\n \n\n- [ENV](<https://delaparra-services.nl/knowledge-hub/env>) \n- [environment](<https://delaparra-services.nl/knowledge-hub/environment>) \n- [Identity & Access Management](<https://delaparra-services.nl/knowledge-hub/identity-access-management>) \n- [Secret Management](<https://delaparra-services.nl/knowledge-hub/secret-management>)\n\n \n\n[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)\n\n[HTML version](https://delaparra-services.nl/skills/laravel-env-config)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://delaparra-services.nl/skills/laravel-env-config#webpage",
                "url": "https://delaparra-services.nl/skills/laravel-env-config",
                "name": "Laravel environment and config | DeLaParra Services",
                "description": "Use when working with environment variables, .env files and configuration in a Laravel app - adding a new setting, APP_KEY, database/mail/queue credentials, config caching, secrets in CI/CD or Docker, or debugging \"env() returns null in production\". Keeps secrets out of Git and config reads cache-safe.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/skills/laravel-env-config#breadcrumb"
                }
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/skills/laravel-env-config#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Laravel environment and config"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "SoftwareSourceCode",
                "@id": "https://delaparra-services.nl/skills/laravel-env-config#skill",
                "url": "https://delaparra-services.nl/skills/laravel-env-config",
                "name": "Laravel environment and config",
                "description": "Use when working with environment variables, .env files and configuration in a Laravel app - adding a new setting, APP_KEY, database/mail/queue credentials, config caching, secrets in CI/CD or Docker, or debugging \"env() returns null in production\". Keeps secrets out of Git and config reads cache-safe.",
                "inLanguage": "en",
                "license": "https://spdx.org/licenses/MIT.html",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/skills/laravel-env-config#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/skills/laravel-env-config#dataset",
                "name": "Laravel environment and config",
                "description": "Use when working with environment variables, .env files and configuration in a Laravel app - adding a new setting, APP_KEY, database/mail/queue credentials, config caching, secrets in CI/CD or Docker, or debugging \"env() returns null in production\". Keeps secrets out of Git and config reads cache-safe.",
                "url": "https://delaparra-services.nl/skills/laravel-env-config",
                "identifier": "https://delaparra-services.nl/skills/laravel-env-config#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/skills/laravel-env-config#skill"
                },
                "creditText": "delaparra-original",
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://spdx.org/licenses/MIT.html",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "dateModified": "2026-11-28T14:00:11+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#skills",
                    "name": "Skills for AI coding assistants",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "laravel-env-config.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/skills/laravel-env-config.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "laravel-env-config.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/skills/laravel-env-config.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "laravel-env-config.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/skills/laravel-env-config.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "laravel-env-config.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/skills/laravel-env-config.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "laravel-env-config.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/laravel-env-config.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "laravel-env-config-files.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/laravel-env-config/download",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    }
                ]
            }
        ]
    }
}