**************************
** LARAVEL VERSION 5.8 **
** PHP VERSION >= 7.1.3 **
**************************
**************************************************
** STEPS BY STEPS CHANGES THAT NEED TO BE DONE **
** TO SETUP LARAVEL FRAMEWORK ON LOCAL **
**************************************************
STEP 1: STEP TO SETUP VIRTUAL DOMAIN FOR LOCAL
STEP 1.1: Edit FILE --- C:\xampp\apache\conf\extra\httpd-vhosts.conf AND ADD BELOW CODE AT BOTTOM
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName j1app.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName j1app.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName evportal.imix.local.com
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName evportal.imix.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName evportal.odc.imix.local.com
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName evportal.odc.imix.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName admin.j1app.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName admin.j1app.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName adminportal.imix.local.com
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName adminportal.imix.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName adminportal.odc.imix.local.com
Options All
AllowOverride All
Require all granted
DocumentRoot "C:/xampp/htdocs/j1app-dvpt/public"
ServerName adminportal.odc.imix.local.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
Options All
AllowOverride All
Require all granted
STEP 1.2: Edit FILE --- C:\Windows\System32\drivers\etc\hosts AND ADD BELOW CODE AT BOTTOM
127.0.0.1 j1app.local.com /** For Front URL **/
127.0.0.1 evportal.imix.local.com /** For Front URL **/
127.0.0.1 evportal.odc.imix.local.com /** For Front URL **/
127.0.0.1 admin.j1app.local.com - /** For Admin URL **/
127.0.0.1 adminportal.imix.local.com - /** For Admin URL **/
127.0.0.1 adminportal.odc.imix.local.com - /** For Admin URL **/
STEP 1.2: Restart XAMPP and RUN XAMPP AS A ADMINISTRATOR
STEP 2: INSTALL COMPOSER ON YOUR MACHINE (https://getcomposer.org/download/) AND FOLLOW STEP FROM THIS REF. LINK
STEP 3: OPEN CMD AND SET YOUR PROJECT FOLDER PATH UNTIL j1app PATH
STEP 4: RUN COMMAND "composer install"
STEP 5: CHECK .env FILE (IF FILE NOT EXIST THEN UPLOAD IT AND CONFIGURE DATABASE CONNECTION)
STEP 5.1 HOW To CONFIGURE DATABASE CONNECTION
1) - CREATE DATABASE NAME j1app-dvpt
- IMPORT FILE FROM FOLDER mysqldb/06_07_2021/j1app-dvpt.zip
- RUN ALL QUERY FROM query_track_2021_07_06.sql FILE
2) - CREATE DATABASE NAME imix_log
- IMPORT FILE FROM FOLDER mysqldb/06_07_2021/imix_log.zip
STEP 6: RUN COMMAND "php artisan config:cache"
STEP 7: RUN YOUR LOCAL DOMAIN (https://j1app.local.com)
==================================================================================================================
**********************************************************
** STEPS BY STEPS CHANGES THAT NEED TO BE DONE **
** TO SETUP SYNCHRONIZE USER DATA BETWEEN IMIX AND ITNDB **
***********************************************************
--------------SET IMIX API SETTINGS IN ITNDB--------------
PAGE: /imix_api_setting.php
1) IMIX API Key:
* Key generate from IMIX:
STEP 1: LOGIN USING DEFAULT AGENCY MANAGER ADMIN IN IMIX ADMIN PANEL (AGENCY NAME LIKE : ITN DB)
STEP 2: GET IMIX API KEY FROM
System Settings > API Settings > API CREDENTIALS
2) IMIX API URL:
* FOR LOCAL: http://admin.j1app.local.com/api/
- USE 'api/' AFTER ADMIN DOMAIN NAME
3) IMIX API Name: IMIX
4) ODCDB API URL:
* FOR LOCAL: http://api.itndb-local.com/v1/
- THIS DOMAIN POINT TO 'itn-odc-dvpt/api_admin_public' DIRECTORY
* SET THIS URL ALSO IN IMIX ADMIN PANEL
- System Settings > System Settings > SOCIAL SETTING
5) SYNCING MODE: ON
AFTER SET THIS INFORMATION SAVE DATA AND TEST CONNECTION
---------------------------------------------------------------
--------------SET ODCDB API SETTINGS IN IMIX--------------
1) SET CURRENT APP URL
* System Settings > System Settings > SOCIAL SETTING
* APP URL: https://j1app.local.com/
2) SET ODC DB API FROM BELOW PAGE
* System Settings > System Settings > SOCIAL SETTING
* ODC DB API SETTING
- ODCDB Api Key: teLMQJeHHnrC18s
- ODCDB Api Secret: bGJYNnEveXJDSEpYaDliYlVzZjRmZz09
- ODCDB Api URL: http://api.itndb-local.com/v1/
* ODCDB Api Key and ODCDB Api Secret GENERATE USING 'test1.php' FILE WHICH IS LOCATED IN ITNDB
==================================================================================================================
**************************************************
** STEPS BY STEPS CHANGES THAT NEED TO BE DONE **
** TO SETUP LARAVEL FRAMEWORK ON LIVE SERVER **
**************************************************
STEP 1: CREATE SUB DOMAIN (e.g. qa.imixonline.com) and This sub domain to point "public" directory.
STEP 2: ALLOW IN php.ini (WHM main php.ini)
- allow_url_fopen = On
- allow_url_include = On
- display_errors = On
- max_input_vars = 1000
- memory_limit = 512M
- post_max_size = 128M
- upload_max_filesize = 128M
STEP 3: RUN COMMAND "composer install" (point to project root directory).
STEP 4: CHECK .env FILE (IF FILE NOT EXIST THEN UPLOAD IT AND CONFIGURE DATABASE CONNECTION)
STEP 5: RUN COMMAND "php artisan config:cache"
STEP 6: RUN YOUR DOMAIN (qa.imixonline.com)
==================================================================================================================
************************************
*** CODING STANDARD Rules ***
************************************
Rule 1: To Create Class name should be written in Capitalize
(e.g class ExampleClass)
Rule 2: The properties of class like method and variables of class should be written in Camel Case
(e.g function exampleMethod(){})
Rule 3: global.php file is created for write global function inside there
global function should be written like below example.
(e.g. function example_function() )
Rule 4: we can define config variables in (config/common.php)
config variable format should be like below example.
(e.g. example_variable => "value" )
Rule 5: Code Structure Example
class ClassName
{
public function methodOne(){
if(condition){
foreach(){
// code
}
}
else{
// code
}
}
}
------------------------------------------------------------
Do:
===
(1) (2)
if(condition) if(condition){
{ foreach(){
foreach() // code
{ }
// code OR }
} else{
} // code
else }
{
// code
}
------------------------------------------------------------
Don't:
======
if(condition){
// code
}else{ // Don't use this method of parentheses
// code
}
==================================================================================================================
**********************************************
*** J1APP API INTEGRATION in Laravel ***
**********************************************
Step 1: Open config/j1appapi.php
Step 2: Set URL according to Local, Development, Live URL of API Server
Step 3: Set APIKey and APIUser according to related server
STEP 4: RUN COMMAND "php artisan config:cache"
======================================================================================================================================
COMMON ARTISAN COMMAND
php artisan config:cache
php artisan config:clear
php artisan cache:clear
php artisan key:generate
======================================================================================================================================
INSTALL PASSPORT
php artisan passport:install
php artisan passport:keys --force
======================================================================================================================================
DUMP AUTOLOAD
composer dump-autoload
php artisan optimize
======================================================================================================================================
Default Database Requirement
----------------------------
Set default values before project going to live
1) Add 'Root Admin' role
2) Add admin with the "Root Admin" role
3) Predefined Permissions groups and permissions
## Truncate bellow Table
1) users
2) user_details
3) user_log
4) portfolio
5) placement
6) socal_authorization
7) resume
8) resume_award
9) resume_certificates
10) resume_education
11) resume_employment
12) lead
13) j1_interview
14) documents
15) agency_contract
16) flight_info
======================================================================================================================================
Instructions for Developer
--------------------------
1) Always define route name while creating new route.
2) Use route name always on every redirection or define url at any place.
3) Always use key name instead of 'ID' at the place where you needed as static code
4) Database queries need to be created manually by developer
roles:
- Developer have to prepare sql query for add role
permission_group:
- Developer have to prepare sql query for add permission group
- specify if the permission group is used as menu section
permissions:
- Developer have to prepare sql query for add permissions
- Specify if the permission is used for menu item
======================================================================================================================================
## Laravel Exception Handling
### 1) Create custom Exception class
#### Example:
```php
// location: app\Exceptions\CustomException
class CustomException extends Exception
{
public function __construct($message = "Unauthorized Access")
{
parent::__construct($message);
}
}
```
### 2) Register your custom exception in laravel exception handler
#### Example:
```php
// location: app\Exceptions\Handler
class Handler extends ExceptionHandler
{
public function render($request, Exception $exception)
{
if($exception instanceof CustomException)
{
return response()->view('errors.error',$data);
}
return parent::render($request, $exception);
}
}
```
### 3) Use custom exception inside the code
#### Example:
```php
use App\Exceptions\CustomException;
throw new CustomException("Test Exception Message");
```
==================================================================
## Laravel Queue Processing
Laravel queues provide a unified API across a variety of different queue backends, such as Beanstalk, Amazon SQS, Redis, or even a relational database. Queues allow you to defer the processing of a time consuming task, such as sending an email, until a later time. Deferring these time consuming tasks drastically speeds up web requests to your application.
### 1) Database migration
- For manual process export both this tables "jobs","failed_jobs"
- DB Migration
```bash
php artisan queue:table
php artisan queue:failed-table
php artisan migrate
```
### 2) update (.env) file
```bash
QUEUE_CONNECTION=database
```
### 3) Running The Queue Worker
queue workers are long-lived processes so this command will run permanently.
```bash
php artisan queue:work
```
### 4) if code updated then need to restart this command.
```bash
php artisan queue:restart
```
### 5) Follow this documentation for automatic settings [supervisor-configuration](https://laravel.com/docs/5.8/queues#supervisor-configuration)
#### Example:
```php
trait MailerTrait
{
public function sendTestMail(){
Mail::send('email.emailTemplate', ['message_text'=>'data'], function ($message) {
$message->to('priyank708@yopmail.com');
});
}
}
```
```bash
php artisan make:job SendTestEmail
```
```php
// Location: app\Jobs\SendTestEmail.php
use MailerTrait;
public function handle()
{
$this->sendTestMail();
}
```
===================================================================
**************************************************
** SHUT ACCESS MODE FOR PROJECT [FILE: app\global.php]**
*DEFAULT VALUE IS 0 *
MAINTENANCE_MODE_ON = 0
MAINTENANCE_MODE_OFF = 0
# ON SHUT ACCESS MODE SET:
MAINTENANCE_MODE_ON = 1
# OFF SHUT ACCESS MODE: Run command
MAINTENANCE_MODE_ON = 0
MAINTENANCE_MODE_OFF = 1
**************************************************