Thavarshan / otrium

πŸ“ˆ A PHP report generator CLI application for Otrium.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Otrium

Introduction

Otrium a fast-growing e-commerce company that serves more than 2 million customers. The company has been running for several years and is now going through its growth stage. This is an internal reporting tool designed with very specific requirements and is highly opinionated.

No frameworks of any type have been used on this application although third-party libraries were incorporated to ease development load.

CI/CD has been set up using Github Actions and can be found here.

Before You Begin

Before you begin we recommend you read about the basic building blocks that assemble the application:

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

  • Git - Download & Install Git. OSX and Linux machines typically have this already installed.
  • PHP - Download & InstallPHP and the PHP package manager composer. If you encounter any problems, you can also use this guide to install PHP.
  • MySQL - Download & Install MySQL, and make sure it's running on the default port (3306).
  • Composer - You're going to use the Composer Package Manager to manage your PHP packages. Make sure you've installed PHP first, then install composer globally:
# MacOS
$ brew install composer
# Windows
$ choco install composer
# Linux
$ sudo apt-get update
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Download

There are several ways you can get the Otrium App:

Cloning The GitHub Repository

The recommended way to get Otrium App is to use git to directly clone the Otrium App repository:

$ git clone https://github.com/Thavarshan/otrium.git

This will clone the latest version of the Otrium App repository to a otrium folder.

Downloading The Repository Zip File

Another way to use the Otrium App is to download a zip copy from the main branch on GitHub. You can also do this using the wget command:

$ wget https://github.com/Thavarshan/otrium/archive/refs/heads/main.zip -O otrium.zip; unzip otrium.zip; rm otrium.zip

Don't forget to rename otrium-main as otrium.

Downloading The Release Build

Yet another way to download the Otrium application is to download the latest release build. You can find the latest release here.

Installation

Once you've downloaded the application and installed all the prerequisites, you're just a few steps away from starting to use the application.

The application comes pre-bundled with a composer.json file that contains the list of packages you need to start your application.

To install the dependencies, run this in the application folder from the command line:

$ composer update

This command does a few things:

  • First it will install the dependencies needed for the application to run.
  • If you're running in a development environment, it will then also install development dependencies needed for testing and running your application.
  • To update these packages later on, just run composer update again.

Dummy Data

Before running the application itself, please import the test data provided in a .sql file located within the data directory. Dates have been modified so the report is generated for dates from the date you provide as an argument or by default today to the past 7 days.

Configurations

Finally from within your command-line inside the downloaded otrium directory run:

$ cp .env.example .env && chmod +x bin/otrium

This is to set the application configurations and prepare them for usage. A file with the name .env or .env.example has been provided with otrium. This is where you may save sensitive information regarding the application for instance the database credentials.

Make sure you rename .env.example to .env and set your MySQL database credentials in the .env file.

Example Configurations
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=otrium
DB_USERNAME=
DB_PASSWORD=

Usage

Running The Application

To run the application. Open up the downloaded directory on your terminal application and run:

$ bin/otrium report:generate daily --from=2018-01-12

or

$ bin/otrium report:generate brand --from=2018-01-12

An argument must be provided when running the application. This is to determine what kind of report is to be generated.

Parameters

Parameters Description Example Value
command Name of the command to be run report:generate
name Name of report to be generated daily/brand
from (optional) Date from which report should be generated 2018-01-12 (Y-m-d)

The generated report CSV files can be found within the reports directory.

Available Reports

  • daily - Generate 7 days turnover (excluding VAT) per day.
  • brand - Generate 7 days turnover per brand (excluding VAT) per day.

Help

If you're not sure about how to run the command or want to know what commands are available run:

$ bin/otrium list

Contributing

Thank you for considering contributing to Otrium! The contribution guide can be found here.

Code of Conduct

To ensure that the Otrium community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Disclaimer

This is an exercise application and not a polished production-ready version. This app should not be used in a production environment and please mind the license provided.

License

This application is open-sourced software licensed under the MIT license.

About

πŸ“ˆ A PHP report generator CLI application for Otrium.

License:MIT License


Languages

Language:PHP 99.8%Language:Shell 0.2%