{"id":15188789,"url":"https://github.com/aiven-labs/aiven-laravel","last_synced_at":"2025-10-02T04:31:34.761Z","repository":{"id":44765711,"uuid":"414353142","full_name":"Aiven-Labs/aiven-laravel","owner":"Aiven-Labs","description":"Extend Laravel PHP framework to make working with Aiven databases simpler","archived":true,"fork":false,"pushed_at":"2023-03-06T14:50:03.000Z","size":28,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":12,"default_branch":"main","last_synced_at":"2024-04-25T23:21:16.166Z","etag":null,"topics":["aiven","artisan-commands","database","laravel","laravel8","mysql","opensearch","postgresql","redis"],"latest_commit_sha":null,"homepage":"","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/Aiven-Labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-06T20:00:18.000Z","updated_at":"2024-04-25T23:21:16.167Z","dependencies_parsed_at":"2023-08-15T18:25:41.169Z","dependency_job_id":null,"html_url":"https://github.com/Aiven-Labs/aiven-laravel","commit_stats":null,"previous_names":["aiven-labs/aiven-laravel","aiven/aiven-laravel"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aiven-Labs%2Faiven-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aiven-Labs%2Faiven-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aiven-Labs%2Faiven-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aiven-Labs%2Faiven-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aiven-Labs","download_url":"https://codeload.github.com/Aiven-Labs/aiven-laravel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234934599,"owners_count":18909696,"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":["aiven","artisan-commands","database","laravel","laravel8","mysql","opensearch","postgresql","redis"],"created_at":"2024-09-27T19:42:33.047Z","updated_at":"2025-10-02T04:31:34.437Z","avatar_url":"https://github.com/Aiven-Labs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aiven Commands for Laravel\n\n**✨ Add some Aiven magic to your Laravel project ✨**\n\nThis Laravel package provides some `aiven` commands for `artisan` to help with managing your development databases and producing the correct configuration to use with them. This version supports both MySQL and PostgreSQL.\n\nUse the commands to:\n* List the Aiven services in your project\n* Power your databases on and off from `artisan`, so you don't leave the meter running when you're not working\n* Get database config you can paste straight into your `.env` file or environment.\n\n## Getting started\n\nInstall the package with [Composer](https://getcomposer.org):\n\n```\ncomposer require aiven/aiven-laravel\n```\n\nYou will need an Aiven account - [sign up for a free trial](https://console.aiven.io/signup?utm_source=github\u0026utm_medium=aiven-laravel) if you don't have one already. Go ahead and create the database(s) you'll be using in your project through the web interface, or investigate the [Aiven CLI](https://developer.aiven.io/docs/tools/cli).\n\nGet an [auth token](https://developer.aiven.io/docs/platform/howto/create_authentication_token) for your Aiven account, and set it as `AIVEN_API_TOKEN` in your environment.\n\nIt's recommended to also set `AIVEN_DEFAULT_PROJECT` as the project in your Aiven account that you'll be using services from (but you can also supply `--project [projectname]` for all the commands instead if you like)\n\n## Usage\n\nGet a list of the Aiven services (databases) available:\n\n```\nphp artisan aiven:list \n```\n\nGet the environment variables to export or paste into `.env` for a particular service:\n\n```\nphp artisan aiven:getconfig --service my-postgres-db\n```\n\n\u003e When you use the `DATABASE_URL` in Laravel, you must remove the existing `DB_HOST`, `DB_PORT`, etc configuration so that it does not conflict.\n\nCheck the status of the service:\n\n```\nphp artisan aiven:state --service my-postgres-db\n```\n\nPower the service on or off:\n```\nphp artisan aiven:powerup --service my-postgres-db\nphp artisan aiven:powerdown --service my-postgres-db\n```\n\nIt's useful to power things down when you're not using them so that you aren't being charged (even if you're still paying in trial credits!)\n\n## Datastore-specific setup\n\n### MySQL and PostgreSQL®\n\nPHP is on good terms with relational databases, and Laravel makes this very straight forward.\n\n1. Remove all the configuration entries from `.env` starting with `DB_`\n\n2. Paste the output of the `aiven:getconfig` command. For both MySQL and PostgreSQL, this is a `DATABASE_URL`. For PostgreSQL, we need to tell Laravel we want to use Postgres (MySQL is the default) so the command also outputs `DB_CONNECTION=pgsql` and this should also be included.\n\n### Redis™*\n\nRedis™ needs some extra dependencies (see [Laravel Redis docs](https://laravel.com/docs/8.x/redis)), and then you can set the `REDIS_URL` to the value returned by `aiven:getconfig`.\n\n### OpenSearch® with Laravel Scout\n\nThis uses some Elasticsearch libraries because the OpenSearch project is a fork so they are reasonably compatible.\n\n* Use [Laravel Scout](https://laravel.com/docs/8.x/scout)\n\n* Add [Explorer](https://jeroen-g.github.io/Explorer/)\n\n* Pin your PHP elasticsearch library dependencies, I have this in `composer.json`:\n\n```\n        \"elasticsearch/elasticsearch\": \"\u003e=7.9 \u003c7.14\",\n```\n\nThe `aiven:getconfig` command will give you just the connection string for an OpenSearch service; put this in the `config/explorer.php` so that it looks something like this:\n\n```\n    'connection' =\u003e \"https://avnadmin:s3cr3t@servicename.aivencloud.com:port\",\n```\n\nThe Scout documentation has a good overview of how to make your models searchable, and the Explorer project adds commands to create the index.\n\n## Troubleshooting\n\n### MySQL primary key errors\n\nLaravel's initial migrations assumes that your MySQL database doesn't enforce primary keys (see [related bug](https://github.com/laravel/framework/issues/33238) for more info) - disable the `mysql.sql_require_primary_key` setting on Aiven if you run into this.\n\n### Connection problems\n\nIf you add the config to your environment and still can't connect, check that you don't have other environment variables with names starting `DB_` ... values like `DB_HOST` should be removed when you use the `DATABASE_URL` field to connect.\n\n## Get in touch\n\nQuestions? Problems? Open an issue and let us know.\n\n## Trademarks\nMySQL, OpenSearch, PostgreSQL and Laravel are trademarks and property of their respective owners. All product and service names used in this website are for identification purposes only and do not imply endorsement.\n\n/* Redis is a trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Aiven Oy is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Aiven Oy.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiven-labs%2Faiven-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiven-labs%2Faiven-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiven-labs%2Faiven-laravel/lists"}