Giter Club home page Giter Club logo

lara-invoices's Introduction

How can we use this repo?

Install

composer install

Next you can clone the .env.example file into the .env file. This means that you have to create the same file in the root directory under a different name e.g. .env and copy paste the same credentials like .env.example file.

Laravel has a built-in CLI tool called artisan. Your application must generate a unique base 64 key that Laravel uses behind the scenes to bootstrap this project.

Command:

php artisan key:generate

It will automatically find your .env file and place the base 64 value in the file.

Output inside the file:

APP_KEY=base64:T0huMR5Wx9EoDmjTxniKTofHD/7cOiDeVVD9eTKuCa0=

Additional Note:

As you can see it is necessary to create the .env file in your local to bootstrap the project. But Laravel contains 2 methods to connect to the database server.

  • Use of the .env variables (I prefer this one)
  • Use of the file located at the config/database.php

Use of the .env variables:

When you create this file with copy paste credentials you can see default; the database variables are written something like this:

DB_CONNECTION=mysql  
DB_HOST=127.0.0.1  
DB_PORT=3306  
DB_DATABASE=test_app  
DB_USERNAME=root  
DB_PASSWORD=

You can edit values according to your own database personal preference. I am using Postgres in this case.

Use of the file located at the config/database.php

Note: When Laravel bootstraps the project it gives priority to the .env file as compared to config/** files. You can see config/database.php file contains an associated array with default database settings like this.

return [
    
    'default' => env('DB_CONNECTION', 'mysql'),
    'connections' => [
        'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],
    ]
    ]

You can only use these settings if variables from the .env file will be deleted. Otherwise, Laravel gives priority to .env variables.

Delete the variables from the .env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test_app
DB_USERNAME=root
DB_PASSWORD=

Lastly, Update the config/database.php with your database server settings:

'default' => env('DB_CONNECTION', 'pgsql')
'database' => env('DB_DATABASE', 'invoicer_test'),
'username' => env('DB_USERNAME', 'postgres'),
'password' => env('DB_PASSWORD', 'a')

Database

I am using Postgres and inside .env file my database server credentials are:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1  
DB_PORT=5432
DB_DATABASE=invoicer_test
DB_USERNAME=postgres
DB_PASSWORD=a

However, your main server and database server get started.

Migration (Transform into real database tables)

At the last make sure after updating your database settings. Please use artisan CLI to migrate the database tables.

php artisan migrate

Deployment

Heroku

lara-invoices's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.