Skip to content

wpget setup local env

Daniele Fontani edited this page Nov 8, 2017 · 9 revisions

Repository folders

  • logs: logs files (git ignored)
  • src: php backend source
    • src-ui: angular 2 based front end application
  • web
    • catalog: rest api for plugin managment and publishing
    • api: rest api for frontend and integration
    • auth: api for authentication
    • ui: dist folder for front-end application (git ignored).
  • vendor: composer vendor folder (git ignored)
  • config contains config files

WpGet Components

WpGet is composed from two components:

  • Backend
  • Front-end

Running backend and frontend

Backend is a slim framework based php application, while frontend is an angular2 application based on primeNG ui framework. In order to run project locally, you have to follow these steps:

  • clone solution
  • Backend
    • open src folder with Visual Studio Code.
    • restore composer dependencies with composer install
    • Run php from the root. This will run the php application.
  • Frontend
    • open src-ui folder with Visual Studio Code.
    • From integrated command line or a regular shell, run npm install
    • From integrated command line or a regular shell, run ng serve to startup application and watch changes
  • Database
    • project is configured to startup over a MySQL database with username\name\password equal to WpGet. Just recreate this locally to startup as-is, or change configuration.

Prerequisites

  • composer installed
  • node installed
  • php 5.6+
  • mysql or other db
  • php.ini:
    • extension=php_mbstring.dll
    • extension=php_pdo_mysql.dll (or other PDO if you preferr othet db than mysql)
    • set timezone, i.e. date.timezone ="Europe/Rome"

Understand Backend

Each application (folder inside "web") contains only one "index.php" file that hosts the slim application. All application share same business logic, data layer and controllers, but expose only what needed. This splitting is done to allow to run application over multiple server or container. There are some custom code upon slim, here a quick list:

  1. ORM: eloquent is used, but a simple framework is developed to manage database migration. Each entity must implement a "TableBase" class, defining field list and table name. The *UpdateManager" class will upgrade db to fit definition.
  2. Routing: All controller are a derivation from "DynamicController". This class allow dynamic invokation of method by namning convention. This will allow to add a route simply adding functions into controllers. i.e. adding function postSave(xxx) into a controller, you are adding a route with method "POST" and {action}=Save in url /ControllerName/{Action}[/{id}]
  3. EntityController: reading from TableBase Implementation you can expose a db table by implementing a single class. This class is basically a controller that inherits from EntityController. You will be able to add other methods than CRUD ones that are provided by design.
  4. DependencyManager: this class will scan folders and include all required files from application.

#Visual Studio Code Packages

  • bmewburn.vscode-intelephense-client
  • brapifra.phpserver