Skip to content

Development of the project "Online Store" Yii2 Framework, PostgreSQL, PHPStrorm

License

Notifications You must be signed in to change notification settings

StudentsProjectsITEA/itea-php-advanced-online-store

 
 

Repository files navigation

Online Store Project | ITEA


Requirements to development

  • PHP version 7.3
  • Nginx
  • Composer
  • Git
  • Software: PhpStorm, ValentinaDB
  • OS: Linux, Mac OS

Preparing project

The first steps after pulling the project to the local machine:

  1. Open a console terminal and install all Composer requirements:
composer install
  1. Execute the init command:
php init --env=Development --overwrite=All
  1. Run the command in terminal one by one to create database:
sudo -u postgres psql postgres
# CREATE USER "store-admin" WITH PASSWORD 'itea1234';
# CREATE DATABASE store_db WITH OWNER "store-admin";
# GRANT ALL PRIVILEGES ON DATABASE store_db to "store-admin";
# \quit
sudo systemctl restart postgresql
  1. Adjust the components['db'] configuration in file /common/config/main-local.php like a:
'db' => [
    'class' => 'yii\db\Connection',
    'dsn' => 'pgsql:host=localhost;dbname=store_db',
    'username' => 'store-admin',
    'password' => 'itea1234',
    'charset' => 'utf8',
],
  1. Open a console terminal, apply migrations with command:
php yii migrate
  1. Configure the virtual host for Nginx and create empty log files like a access_log and error_log sections:
server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name online-store.site;
    root        /home/username/projects/online-store/frontend/web/;
    index       index.php;

    access_log  /home/username/projects/online-store/frontend/runtime/logs/frontend-access.log;
    error_log   /home/username/projects/online-store/frontend/runtime/logs/frontend-error.log;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        try_files $uri =404;
    }
    error_page 404 /404.html;

    # deny accessing php files for the /assets directory
    location ~ ^/assets/.*\.php$ {
        deny all;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        try_files $uri =404;
    }

    location ~* /\. {
        deny all;
    }
}

Thereafter your web server domens are:

http://online-store.site/ - for frontend
http://online-store.site/admin/ - for backend
  1. Change the hosts file to point the domain to your server. Path to hosts file in Linux: /etc/hosts and add the following lines:
127.0.0.1   online-store.site
  1. If the system does not automatically create log files, run the command in terminal to create them:
./makelogfiles
  1. For development, you can create test data for working with the project:
php yii test-data/add - to add test data
php yii test-data/delete - to delete test data

After insertion test data, you can sign in to app using the following data:

For frontend:
⋅ username: store-user
⋅ password: itea1234

For backend:
⋅ username: store-admin
⋅ password: itea1234

Contacts: pro100rost, for-web-an

Enjoy :)

About

Development of the project "Online Store" Yii2 Framework, PostgreSQL, PHPStrorm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 79.2%
  • CSS 14.6%
  • JavaScript 5.1%
  • Shell 0.5%
  • TSQL 0.5%
  • Batchfile 0.1%