Skip to content

Commit

Permalink
Merge pull request #2 from rootinc/develop
Browse files Browse the repository at this point in the history
Update package name
  • Loading branch information
jaredrhodes authored Apr 9, 2019
2 parents 013ccaf + e612684 commit d207c17
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Laravel Database URI
Drop-in package to translate a database URI into database config values. No more need to add logic to your
# Laravel Database URL
Drop-in package to translate a database URL into database config values. No more need to add logic to your
`config/database.php` file.

This is meant to help prevent the need for manually parsing database URIs, like the ones that come from Heroku or AWS.
It will take a URI and assign host, password, username, port, (etc.) components to the default driver or
This is meant to help prevent the need for manually parsing database URLs, like the ones that come from Heroku or AWS.
It will take a URL and assign host, password, username, port, (etc.) components to the default driver or
specific driver(s) of your choosing.

This __will override__, at runtime, any `default` database connection values for `host`, `port`, `username`, `password`, and `database`
Expand All @@ -14,12 +14,12 @@ This __will override__, at runtime, any `default` database connection values for
- Laravel >= 5.6

## Installation
`$ composer require rootinc/laravel-db-uri`
`$ composer require rootinc/laravel-db-url`

## Configuration
The package will automatically map the parsed values from the environment variable `DATABASE_URL` to the `default` database connection.

Add a `DATABASE_URL` entry to your `.env` or server environment with a URI to your default database.
Add a `DATABASE_URL` entry to your `.env` or server environment with a URL to your default database.
`DATABASE_URL=postgresql://username:password@localhost:5432/database-name`

This will overwrite database connection values for `host`, `port`, `username`, `password`, and `database`
Expand All @@ -28,12 +28,12 @@ This will overwrite database connection values for `host`, `port`, `username`, `
## Customization
Override default behaviour by publishing the config file and setting values.

`$ php artisan vendor:publish --tag=db-uri`
`$ php artisan vendor:publish --tag=db-url`

Set any database connections by supplying `default` or the key path, like `connections.pgsql`, or `redis`
to have a URL mapped onto the connection at that key path.

config/db-uri.php
config/db-url.php
```
return [
'default' => 'SOME_DATABASE_URL', // "default" resolves key path from default key
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rootinc/laravel-db-uri",
"description": "Translates a database URI into Laravel database driver values.",
"name": "rootinc/laravel-db-url",
"description": "Translates a database URL into Laravel database driver values.",
"keywords": ["php", "laravel", "database", "env"],
"type": "library",
"require": {
Expand All @@ -16,13 +16,13 @@
],
"autoload": {
"psr-4": {
"RootInc\\LaravelDbUri\\": "src/"
"RootInc\\LaravelDbUrl\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"RootInc\\LaravelDbUri\\LaravelDbUriServiceProvider"
"RootInc\\LaravelDbUrl\\LaravelDbUrlServiceProvider"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Rootinc\LaravelDbUri;
namespace Rootinc\LaravelDbUrl;

use Illuminate\Support\ServiceProvider;

class LaravelDbUriServiceProvider extends ServiceProvider
class LaravelDbUrlServiceProvider extends ServiceProvider
{

/**
Expand Down Expand Up @@ -33,15 +33,15 @@ public function boot()
public function register()
{
$this->publishes([
__DIR__.'/config/db-uri.php' => config_path('db-uri.php')
], 'db-uri');
__DIR__.'/config/db-url.php' => config_path('db-url.php')
], 'db-url');

$this->mergeConfigFrom(
__DIR__.'/config/db-uri.php', 'db-uri'
__DIR__.'/config/db-url.php', 'db-url'
);

// All driver/connection mappings from config
$connections = config('db-uri');
$connections = config('db-url');

// Loop and set each connection
foreach($connections as $driver_path => $connection_key) {
Expand Down
File renamed without changes.

0 comments on commit d207c17

Please sign in to comment.