laravel

Laravel & pgAdmin download, install and configuration

Step 1: Download pgAdmin for window

To download this you should go to the link below:

https://www.pgadmin.org/download/

pgAdmin

After you get all the installation done, the dashboard of pgAdmin will pop up on your screen.

Step 2: pgAdmin and laragon configuration

After the installation of pgAdmin is done, the app will ask for your password to be set, so type in your password and remember that because it is your access password later on.

Next click on servers tag.

laragonPostgre

Next, create your database as the picture above

Now you can start creating your own table and data.

Step 3: Project configuration

1/ Backend .env file

First, create a new [.env] file by copying from  [.env.example] and then you must have some change to get your backend to be able to connect to the PgAdmin database.

Laravel’s default [.env] file contains some common configuration values that may differ based on whether your application is running locally or on a production web server. These values are then retrieved from various Laravel configuration files within the config directory using Laravel’s env function.

If you are developing with a team, you may wish to continue including a [.env.example] file with your application. By putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.

The changes should look like the picture below:

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME=postgres
DB_PASSWORD=

Next, the most important step is to install a composer for your backend.

Run the command below to install composer:

composer i (run)

Note: if you have any error occurredduring the installation time then you should change the command like below:

composer install –ignore-platform-reqs

This command helps to avoid any server resistance or conflict set up.

Next, on your project you need to do some Config [backend] to migrate Postgres-Schemas and Seed-Data so just do this by follow the steps below:

php artisan key:generate
php artisan jwt:secret
php artisan cache:clear
php artisan config:clear

In case you get your migration stuck or it’s simply not working then just run the command below to go back to the previous stage of your DB.

php artisan:rollback

Then just migrate your table again.

php artisan migrate

Use command php artisan serve to activate the backend side.

2/ [php.ini] file configuration

Config [php.ini] to enable pgsql connection.

You should be able to find it in your xampp application location. the path looks like: (C:/xampp/php/php.ini)

Search “pgsql” in the [php.ini] file. => Enable 2 extensions like the picture below.

3/ Front-end environment file

An Angular Application Environment is JSON configuration information that tells the build system which files to change when you use ng build and ng serve.

Let’s say you have a back end REST API deployed on a server that provides services to your Angular application. You might have a URL for your own development server, another for the test server, and another for the production server. Using Angular Application Environments you can set up three configurations and specify which to use for ng build and ng serve.

Basically, you need to create your new environment.ts file from environment.ts.example and then adjust like picture below:

That is this, thanks for reading this article. Hope you enjoy this and find it helpful in some way. Enjoy coding!

Leave a Comment