/self-recruiting-panel

My pet project. A panel what works with Rest-API at YII2

Primary LanguagePHP

Self Recruiting Panel

What is this repository for?

  • This is my pet project. Project based at Yii2 Minimal
  • Have no version

How do I get set up?

  • Summary of set up
  • Configuration
  • Dependencies
  • Database configuration
  • How to run tests
  • Deployment instructions

Contents:

  1. PROJECT STRUCTURE
  2. APPLICATION STRUCTURE
  3. REQUIREMENTS
  4. INSTALLATION
    1. Create project's dir
    2. Get project via git
    3. Install vendor via composer
    4. Create log files (optional)
    5. Prepare server
    6. Set permissions
    7. Create database
  5. CONFIGURATION
    1. Configuration of Database
    2. If deployed to production
  6. Check your local web-site
  7. Future changes

MY PROJECT STRUCTURE (general)

>> back to contents <<

  home/                 contains all main work code what you can not get outer from server.
  home/apps/            contains all application.
  home/myLittleHelper/  contains my little script what helps me write configuration for Application
  home/yii2/            contains yii2-framework and composer for update.
  home/yii2/vendor      contains yii2-frameworks dependent 3rd-party packages.
  www/                  contains the entry script and Web resources      

APPLICATION STRUCTURES

>> back to contents <<

For details about structure into application better look any Yii2 doc

REQUIREMENTS

>> back to contents <<

The minimum requirement by this application template that your Web server supports PHP 5.4.0.

INSTALLATION:

  1. Create project's dir
  2. Get project via git
  3. Install vendor via composer
  4. Create log files (optional)
  5. Prepare server
  6. Set permissions
  7. Create database

>> back to contents <<

1) Create a dir.

>> back to installation <<

Create a dir where you want to create that project, on your taste.

2) Get project via git.

>> back to installation <<

Following commands will downloading project to your directory:

$ git init
$ git clone https://github.com/planet17/self-recruiting-panel .

3) Install vendor via Composer.

Use composer for get vendor part of project. If you do not have Composer, you may install it by following instructions at getcomposer.org.

After installing Composer, run the following command to install the Composer Asset Plugin:

$ php composer global require "fxp/composer-asset-plugin:~1.1.0"

If you have Composer and Plugin yet, then just install vendor via composer using the following command at home/yii2 dir:

$ cd home/yii2 
$ php composer install

NOTES: If you get error with fxp like:

[ReflectionException] - Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

Use following command to fix it:

$ composer global update fxp/composer-asset-plugin --no-plugins

4) Create log files [optional].

>> back to installation <<

Create files for logs [optional - if you don't need this you can skip this step] You can create dir and files using the following command:

$ mkdir log
$ touch log/access.log|touch log/error.log

5) Prepare server.

>> back to installation <<

Prepare your server. Add domain to your host. I run my app at my local. I use it at my:

Ubuntu 14.04.4 LTS
Server an Apache >= 2.4 or Nginx >= 1.4
PHP >= 5.6

So as example add domain to my hosts:

127.0.0.1	http://[my.domain.name]

Use following command:

$ sudo gedit /etc/hosts 

b) Example of my settings for Apache2:

<VirtualHost 127.0.0.1:80>
	DocumentRoot [path-to-the-dir]/www
		<Directory [path-to-the-dir]/www>
			Options Indexes FollowSymlinks
			AllowOverride All
			Require all granted
		</Directory>
	ErrorLog [path-to-the-dir]/log/error.log
	CustomLog [path-to-the-dir]/log/access.log combined
</VirtualHost>
  • About add an ErrorLog and CustomLog is optional, so if you don't create logs dir above...

I use single file for all my setting of apache. I almost sure what you use other way to configuration. So be care, cause you might to do other actions. But anyway for example (If you need it). I write sets from above to the file from the following command:

$ sudo gedit /etc/apache2/sites-enabled/000-default.conf

c) And finally for preparing server you can restart it by following command:

$ sudo service apache2 restart

6) Set permissions.

>> back to installation << Now setting of permission don't work automatically, so you need using the following command:

TODO COMPLETE AFTER PROJECT WILL COMPLETELY FINISHED AT STRUCTURE LEVEL

$ chmod 777 home/apps/common/runtime
$ chmod 777 home/apps/web/runtime
$ chmod 777 home/apps/api/runtime
$ chmod 777 www/assets

7) Create database.

>> back to installation <<

I create database and user through bash, you can use any other way at your taste. For example I marked only password but you can change DATABASE NAME and USER too. Any restrictions for that.

Get access to database by following command:

$ mysql -h localhost -u root -p

Then into MySql console I use following commands:

CREATE DATABASE srp_db CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'srp_manager'@'localhost' IDENTIFIED BY '[your_password]';
GRANT ALL PRIVILEGES ON srp_db . * TO 'srp_manager'@'localhost';
FLUSH PRIVILEGES;
quit

TODO that item. Create all tables by migrates through Yii-console-application. Go to home/yii2 and using the following Yii-command:

$ cd home/yii2
$ php yii migrate/new
$ php yii migrate

CONFIGURATION

>> back to contents <<

DATABASE

You need rename file /home/apps/common/config/db-local.php-dist, to php extension. Also edit this file with real data, for example:

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=srp_db',
    'username' => 'srp_manager',
    'password' => '[your_password]',
    'charset' => 'utf8',
];

ABOUT PREPARING FOR PRODUCTION

  • Don't forget that instructions only about development version. When you need prepare project to PRODUCTION you need changes into /www/index.php, just comment following:
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

And also you need set-up all other configuration file server-version what you will have:

  1. /home/apps/common/config/db-server.php

NOTES:

  • All command work relatively to root-dir of project. I usually use terminal into my IDE, so I don't need to write a full path.
  • Yii won't create the database for you, this has to be done manually before you can access it.
  • Check and edit the other files in the config/ directory to customize your application as required.

Congratulations

>> back to contents <<

Now you should be able to access the application through the following URL, assuming your server webroot is pointed to www directory.

http://[my.domain.name]/

Login and password to panel:

lgn:    demo@demo
pwd:    demodemo

NOTES:

  • If you get an error 403 with htaccess while following URL, it is might be cause you download project by zip-archive or any other way, what is reason for wrong permission in project. Following command help you fix it:
$ find ./ -type f -exec chmod 0644 {} \;
$ find ./ -type d -exec chmod 0755 {} \;

After used it, you might be need set-up permissions again.

Future changes

>> back to contents <<

Look `REQUIREMENTS.md` for that.

================================ >> back to top <<