Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

falsovsky/idlerpg-site-ng

Repository files navigation

IdleRpg Site NG

Codacy Badge CodeFactor Scrutinizer Code Quality Build Status Coverage Status

Introduction

This is a rewrite of the original site from http://idlerpg.net/ using Zend Framework 3. See a live demo at http://idle.deadbsd.org/.

Installation

The easiest way to install the site is to use Composer. If you don't have it already installed, then please install as per the documentation.

To create your new idlerpg-site-ng:

$ git clone https://github.com/falsovsky/idlerpg-site-ng.git path/to/install

Edit the default configuration file to set the path to your bot files, bot name, etc:

$ cd path/to/install
$ cp config/autoload/local.php.dist config/autoload/local.php
$ nano config/autoload/local.php

Now lets install the PHP dependencies via composer (Choose "Do not inject" if asked):

$ composer install

Once everything is installed, you can test it out immediately using PHP's built-in web server:

$ php -S 0.0.0.0:8080 -t public/ public/index.php
# OR use the composer alias:
$ composer run --timeout 0 serve

This will start the cli-server on port 8080, and bind it to all network interfaces. You can then visit the site at http://localhost:8080/

Note: The built-in CLI server is for development only.

Development mode

The site ships with laminas-development-mode by default, and provides three aliases for consuming the script it ships with:

$ composer development-enable  # enable development mode
$ composer development-disable # disable development mode
$ composer development-status  # whether or not development mode is enabled

You may provide development-only modules and bootstrap-level configuration in config/development.config.php.dist, and development-only application configuration in config/autoload/development.local.php.dist. Enabling development mode will copy these files to versions removing the .dist suffix, while disabling development mode will remove those copies.

Development mode is automatically enabled as part of the site installation process. After making changes to one of the above-mentioned .dist configuration files you will either need to disable then enable development mode for the changes to take effect, or manually make matching updates to the .dist-less copies of those files.

Running Unit Tests

To run the supplied site unit tests, you need to do one of the following:

$ ./vendor/bin/phpunit

If you need to make local modifications for the PHPUnit test setup, copy phpunit.xml.dist to phpunit.xml and edit the new file; the latter has precedence over the former when running tests, and is ignored by version control. (If you want to make the modifications permanent, edit the phpunit.xml.dist file.)

Using docker-compose

This site provides a docker-compose.yml for use with docker-compose; it uses the Dockerfile provided as its base. Build and start the image using:

$ docker-compose up -d --build

At this point, you can visit http://localhost:8080 to see the site running.

You can also run composer from the image. The container environment is named "zf", so you will pass that value to docker-compose run:

$ docker-compose run zf composer install

Web server setup

Apache setup

To setup apache, setup a virtual host to point to the public/ directory of the project and you should be ready to go! It should look something like below:

<VirtualHost *:80>
    ServerName idlerpg.localhost
    DocumentRoot /path/to/idlerpg/public
    <Directory /path/to/idlerpg/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
        <IfModule mod_authz_core.c>
        Require all granted
        </IfModule>
    </Directory>
</VirtualHost>

Nginx setup

To setup nginx, open your /path/to/nginx/nginx.conf and add an include directive below into http block if it does not already exist:

http {
    # ...
    include sites-enabled/*.conf;
}

Create a virtual host configuration file for your project under /path/to/nginx/sites-enabled/idlerpg.localhost.conf it should look something like below:

server {
    listen       80;
    server_name  idlerpg.localhost;
    root         /path/to/idlerpg/public;

    location / {
        index index.php;
        try_files $uri $uri/ @php;
    }

    location @php {
        # Pass the PHP requests to FastCGI server (php-fpm) on 127.0.0.1:9000
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME /path/to/idlerpg/public/index.php;
        include fastcgi_params;
    }
}

Restart the nginx, now you should be ready to go!

QA Tools

# Run CS checks:
$ composer cs-check
# Fix CS errors:
$ composer cs-fix
# Run PHPUnit tests:
$ composer test