Overview
F-Webshop is a modern e-commerce solution for PHP, based on Symfony Framework. It offers flexible, scalable eCommerce solutions designed to help you grow and succeed online. Our cost-effective technology platform makes it possible for you to control the content, functionality, and look and feel of your online store. This solution is aimed to centralize all the marketing data, to enrich, translate and prepare it for exports to multiple channels. It is a productivity tool helping the contributors to serve the product information in different languages and for different purposes. Easy to use and very flexible, the solution can adapt to your product organization and processes, not the other way around. This documentation assumes you have a working knowledge of the Symfony Framework. If you're not familiar with Symfony, please start with reading the Quick Tour from the Symfony documentation.
Conventions and rules
F-Webshop uses Symofony coding standards in php code.
Symfony2 Coding Standards rules for PHP Code Sniffer are maintained in this GitHub repository by the community. Symfony2-specific coding standards are easy to add in PHP Code Sniffer, so that Symfony Coding Standards violations will be shown in the IDE editor along with standard PHP Code Sniffer notifications. PHP Code Sniffer is a tool designed to detect violations of a defined coding standard. It is an essential development tool that helps ensure your code remains clean and consistent. It can also help prevent some common semantic errors made by developers. To install and set up this validation tool, please follow the installation instructions
For javascript, in most cases, we follow the Airbnb JavaScript Style Guide.
For CSS, in most cases, we follow Airbnb CSS / Sass Styleguide.
Technology stack
With F-Webshop, developers find themselves working with some of the most advanced tools and techniques of building a modern e-commerce store, or upgrading an existing one. In this section, we provide a complete overview of the software technology stack, and describe all major elements of the technology stack as well as provide some useful links.
Version Control - GIT
Version Control repository management services are a key component in the software development workflow. Git is the actual technology for source control, and GitLab is the Web UI or interface for Git. GitLab is an online Git repository manager with a wiki, issue tracking, CI and CD. It is a great way to manage git repositories on a centralized server. GitLab gives you complete control over your repositories or projects and allows you to decide whether they are public or private for free.
PHP
F-Webshop requires >= PHP 7.1 by default. Besides, it will also work with PHP 7.2. The support for the new version of PHP makes the platform much faster and significantly simplifies a coding routine.
There are also PHP extensions required by F-Webshop:
- php7.1-fpm
- php7.1-cli
- php7.1-pgsql
- php7.1-curl
- php7.1-dev
- php7.1-gd
- php7.1-gmp
- php7.1-json
- php7.1-mysql
- php7.1-readline
- php7.1-recode
- php7.1-xml
- php7.1-xmlrpc
- php7.1-bz2
- php7.1-imap
- php7.1-intl
- php7.1-fpm
- php7.1-mcrypt
- php7.1-soap
- php7.1-zip
- php7.1-bcmath
- php7.1-imap
- php7.1-cgi
- php7.1-mbstring
- php-amqp
- php-imagick
- php-apcu
- php-memcached
- php-http
- php-memcache
- php-oauth
- php-zmq
- php-geoip
- php-igbinary
- php-oauth
- php-pear
Symfony framework
Symfony is a PHP framework and a set of reusable PHP components used in ecommerce application. F-Webshop uses bits out of different symfony bundles, such as FOSUserBundle, SncRedisBundle, FOSJsRoutingBundle, etc. Instead of directly relying on Symfony request flow, it utilizes its own adapters and interfaces used for tunneling calls to service managers and repositories. It is highly recommended to use the official F-Webshop request flow to avoid problems related to the platform’s internal changes. Twig is a fast, flexible, and secure PHP template engine supported in our app. It is a F-Webshop technology stack component that will essentially simplify your work with themes and templates. You can find the Twig template engine 2 here.
Symfony coding standrands
These Symfony coding standards are based on the PSR-1, PSR-2 and PSR-4 standards, so you may already know most of them. PSR-0 is the default autoloading standard, PSR-1 is a set of basic coding standards, while PSR-2 is a coding style guide. Since PSR-0 has been marked as deprecated, PSR-4 is recommended as its replacement. As for PSR-3, it defines a logger interface that allows writing reusable code independent from any particular logging implementation.
Composer
Composer introduces a dependency management package for PHP.
F-Webshop not only supports it out-of-the-box, but Composer is among key system requirements of the ecommerce platform. You can check how to install Composer here.
Nginx
Another technology stack component is Nginx – a reverse proxy server for such protocols as HTTPS, HTTP, POP3, SMTP, and IMAP. Besides, it is a load balancer, an HTTP cache, and an origin web server. The project is focussed on high performance and concurrency as well as low usage of memory.
MySQL or MariaDb
Many of the world’s largest websites rely on MySQL for years, and now F-Webshop also incorporates this open source database. The solution helps to save time and money powering your high-volume F-Webshop project. The ecommerce platform uses MySQL database triggers during reindexing. At the same time F-Webshop supports MariaDb database server.
Nodejs and npm packages
As Wikipedia states: “Node.js is a packaged compilation of Google’s V8 JavaScript engine, the libuv platform abstraction layer, and a core library, which is itself primarily written in JavaScript.” Beyond that, it’s worth noting that Ryan Dahl, the creator of Node.js, was aiming to create real-time websites with push capability, “inspired by applications like Gmail”. In Node.js, he gave developers a tool for working in the non-blocking, event-driven I/O paradigm. Originally, it was intended as a server environment for applications, but developers started using it to create tools to aid them in local task automation. Since then, a whole new ecosystem of Node-based tools (such as Grunt, Gulp and Webpack) has evolved to transform the face of front-end development. To make use of these tools (or packages) in Node.js we need to be able to install and manage them in a useful way. This is where npm, the Node package manager, comes in. It installs the packages you want to use and provides a useful interface to work with them.
There are also npm required globaly installed by F-Webshop:
- uglify-es
- uglifycss
- ember-cli
- bower
- webpack
For additional packages you can see package.json file in project folder.
Redis
Redis is an open source, in-memory data structure server with advanced key-value cache and store, often referred to as a NoSQL database. It is also referred to as a data structure server, since it can store strings, hashes, lists, sets, sorted sets, and more. The essence of a key-value store is the ability to store some data, called a value inside a key. This data can later be retrieved only if we know the exact key used to store it.
As a redis client we use Predis. It is well written and has a lot of support from the community. Predis is by default integrated with SncRedisBundle
Additional technologies
- HTML
- CSS
- jQuery (primary JavaScript library)
- Ember.js
- Third-party js and jquery libraries
- Varnish is a reverse-web-proxy-caching system designed by Varnish Software to accelerate content-heavy websites. Many web requests produce an identical response, therefore a website will run more efficiently if these responses are cached rather than generated. Varnish stores its cache in virtual memory instead of on the hard drive, thereby conserving CPU resources otherwise consumed by these repeated requests. This accelerates the website's function as Varnish increases the rate at which it responds to requests.
Architectural diagram
Understanding layered software architecture is essential for understanding basic F-Webshop product organization. In this section we are going to provide a detailed explanation of each of the layers in F-Webshop and the way they are used in application.
Persistence layer
In this system, the object model has a repository service that maps an object to one or more rows of the database. A repository service is responsible for performing functions such as: Implementation of all CRUD applications, that is, the repository service containing the SQL code to complete these requests. If you return multiple items in a database query, you can implement a special type of model feature known as collection, which is a class that carries several models in an array-like structure based on a set of rules. This is similar to an SQL clause WHERE. A simple repository service defines and interacts with a single table. However, some objects have a number of attributes or they might have a set linking objects that have a varying number of attributes.
Domain layer
Most importantly, the domain layer contains the domain php models and doctrine mapping annotations. Also classes describing business interactions and corresponding domain events belong here. Last but not least, also custom value objects that are important to the domain are stored here.
All classes and interfaces defined in this layer have no dependencies to any third party library.
Business logic layer
The Business layer binds the elements defined in the domain layer to a specific platform in order to have a runnable application. The layer can for example act as an adapter/wrapper for specific persistence tasks or provide application services (such as email, caching, message queues, etc.). In case of F-Webshop, the business layer also contains console commands the application may have or EventListeners that listen to Symfony-specific or custom events through the frameworks event system. In general, the layer contains the actual implementations of the business services described in the domain layer. Hence, also most dependency injection definitions point to implementations defined in this layer.
Presentation layer
The presentation layer for Web view contains all resources concerned with creating a user interface rendered on the server side for the end user. JavaScript based user interfaces typically only require the API layer and there is thus no need for an extra presentation layer. This means that web based controllers, forms with input validation and Twig view scripts are stored in this layer.
Having separated the user interface from the domain and the infrastructure simplifies the development of either layer. The code in the presentation layer should not contain any business logic, but only forward calls to the respective services of the domain layer. Hence, the presentation layer stays small helping developers to easily evolve the user interface, even during big changes.
The API layer provides an API interface to interact with the application. For example, this could be a REST API backend for a modern JavaScript-based frontend. The layer defines routes and controllers that trigger the corresponding operations in the domain layer.
Having the offered API separate from the implementation allows to precisely define which services are exposed to whom through the API. The layer handles authentication and authorization with the API and can also rate-limit requests or track metrics for billing purposes. Putting all these API concerns into this separate layer allows the domain and infrastructure layers to remain slim and focused, while the exposed API can easily be managed.
Full app data flow can be seen in the picture below:
System Requirements
Here you will find the list of system requirements that have to be adhered to be able to use F-Webshop. First of all have a look at the requirements for running Symfony.
Operating Systems
The recommended operating systems for running app are the Unix systems:
- Ubuntu 16.04 or highter
- Debian 8 or highter
Web server and configuration
In the production environment we do recommend using Nginx web server ≥ 1.10.
Go there to see the full reference to the web server configuration.
PHP required modules and configuration
PHP version: >= php7.1
PHP extensions:
- php7.1-fpm
- php7.1-cli
- php7.1-pgsql
- php7.1-curl
- php7.1-dev
- php7.1-gd
- php7.1-gmp
- php7.1-json
- php7.1-mysql
- php7.1-readline
- php7.1-recode
- php7.1-xml
- php7.1-xmlrpc
- php7.1-bz2
- php7.1-imap
- php7.1-intl
- php7.1-fpm
- php7.1-mcrypt
- php7.1-soap
- php7.1-zip
- php7.1-bcmath
- php7.1-imap
- php7.1-cgi
- php7.1-mbstring
- php-amqp
- php-imagick
- php-apcu
- php-memcached
- php-http
- php-memcache
- php-oauth
- php-zmq
- php-geoip
- php-igbinary
- php-oauth
- php-pear
PHP configuration settings:
- memory_limit: ≥1024M
- date.timezone: Europe/Belgrade
Database
By default, the database connection is pre-configured to work with a following Mariadb configuration >=10.3.
Of course you may use MYSQL database engine >= 5.7.
Redis
By default, the redis connection is pre-configured to work with a latest Debian based stable release.