StackSync is a simple, lightweight and native fullstack PHP mini-framework.

Overview

Software License Latest Version

Introduction

StackSync is a simple, lightweight and native fullstack PHP mini-framework.

It is not a fully fledged framework and does not have all the complex features and the level of polish of other frameworks that are built by communities of professionals, therefore it is not suitable for big commercial projects or for other compagnies to use.

But it can still create powerful applications, and is more destined to be used by beginners and other developpers for personal projects.

Designed to be easy of use while having a strong foundation of the web stack of PHP, MySQL, HTML, JavaScript and CSS (or SASS/SCSS).

Requires basic knowledge of APIs, JSON, Object Oriented Programming.

The code is heavily commented and provides some examples and explanations, for a more detailed rundown, make sure to read through the documentation that covers every aspect of the mini-framework and get started.

Table of Contents

Setup

Installation

Composer is required.

StackSync is available as a composer package, you can create a new StackSync project by running the command below in your terminal while defining the targeted folder:

composer create-project khomsiadam/stacksync project-name

Alternatively, you can download or clone the repository, then open the project and run the following command in your terminal:

composer install

This installs the dependencies for php-jwt and phpdotenv which are the only required packages.

Back to top

Configuration

After creating your database, in your root directory, you will find a .env.example file. Copy and rename to .env and start filling in your database informations:

# Database Credentials: *fill with your proper database information
DB_HOST=
DB_NAME=
DB_USER=
DB_PASS=

# Data Source Name: *do not modify! $_ENV['DSN'] is used as first argument for your PDO connection
DSN=mysql:host=${DB_HOST};dbname=${DB_NAME}

# Errors and responses status for error handling for the API:
ERRORS=ON
RESPONSES=ON

# Database User Table:
USER_TABLE=user

# Database User Columns (add any needed variable for every column added in user table):
USER_ID=user_id
USER_EMAIL=email
USER_PASSWORD=password

# Database Audience Table: *The recipient table for account for 'aud' in JWT token payload
AUDIENCE_TABLE=
# Database Other Tables: *Other tables you may need, as argument for your CRUD operations in controller methods
EXAMPLE_TABLE=

# API Token Authentication Secret Keys: *fill with your own key or add new keys as needed
SECRET_KEY=

Opening your terminal, navigating to your project folder:

cd project-name

Then running this command:

composer serve:local

Will run PHP's built in development server on your local machine and browsing to http://localhost:8080 will show a welcome homepage.

Back to top

Directory Structure

app/                            # The app folder is your backend folder with the main structure
|
|– config/                      # Folder containing your database, constants configuration along with the Middleware
|
|– controllers/                 # Folder containing all your controllers
|
|– core/                        # Contains the core of the mini-framework: Router, Component View system, File generation
|   |
|   |– templates/               # Folder that contains templates for file creation
|
|– migrations/                  # Any generated migration file will be here
|
|– models/                      # Folder containing all your models
|
|– seeders/                     # Any generated seeder file will be here
|
|– views/                       # Contains all files that forms a view. The content files are in the root of this folder
|   |
|   |– components/              # For view components (dynamic/static)
|   |   |
|   |   |- dynamic              # Dynamic components: part of the content
|   |   |
|   |   |- static               # Static components: part of the layout
|   |
|   |– layouts/                 # Layouts for views containing static components and the content
|
|– Application.php              # The main file that runs the application 
|
public/                         # The public folder is your frontend folder where all your assets are with the index.php file
|
|– css/                         # Folder to contain stylesheets
|
|– fonts/                       # Folder for hosting your fonts to be used with @font-face rule
|
|– icons/                       # Contains your icons
|
|– images/                      # Contains your images
|
|– js/                          # Folder for all your javascript files, libraries, modules
|
|– scss/                        # Folder to contain your SASS/SCSS files or the architecture included if used
|
|– index.php                    # Where the requests are redirected to. Routes are defined here.
|
vendor/                         # Packages folder
|
.env                            # Environement variables
|
composer.json                   # Project properties, meta data and dependencies

For a more detailed view on the directory structure be sure to check it's section in the documentation as it also provides some basic insights.

Back to top

Advanced

This section dives deepers and covers all the important aspects and features.

API: The mini-framework's custom API system and the Middleware.

Controllers & Models: How controllers and models are setup.

Routing: Routing configuration for both Web routes and API endpoints.

Views: Views are managed with a Components Views System.

Migrations: A simple migrations system.

Seeding: Seed pre-defined data to your tables.

Back to top

Commands

With the help of composer, there are a multiple of useful custom commands to execute in your terminal.

  • Run PHP's own development server on your local machine (localhost:8080):
composer serve:local
  • Run PHP's own development server on your local network. The address is your local IP address in your network and it can accessed by any device in the same network (ex: 192.168.1.2:8080):
composer serve:remote

*The :8080 is the default port but it can be modified in composer.json.

  • Apply the current migrations in app/migrations folder in the defined sequencing order:
composer migrate:apply
  • Drop the current applied migrations in your database. Only tables applied through the migrations system will be dropped. Any table created normally won't be affected:
composer migrate:drop
  • Run all seeders defined in app/seeders/DatabaseSeeder.php:
composer seed:all
  • Run the app/seeders/UserSeeder.php for seeding the user table:
composer seed:user

*Any created seeder can be added in app/seeders/DatabaseSeeder.php and/or have a custom script added for it under the scripts section in composer.json to be run individually.

  • Alternatively, you can apply current migrations then run all seeders defined:
composer migrate:apply:seed
  • Create a migration file while asking for it's order (that defines it's prefix and id), type (create or update), table name, auto-incremented or generated id, foreign key references and constraints:
composer make:migration
  • Create a seeder file while asking for the targeted table name, is the id auto-incremented or generated, import of column names as keys with empty values to be filled:
composer make:seeder
  • Creates both a controller and a model since they rely on each other while asking for the targeted table name, is the id auto-incremented or generated. Everything is setup automatically based on the tables columns and basic CRUD methods are defined by default for a quick start and as a base for custom methods:
composer make:controller
  • Enables / disables error handling:
composer errors:on
composer errors:off
  • Enables / disables responses from the API:
composer responses:on
composer responses:off

Back to top

Contributions

Contributions are welcome. To discuss any bugs, problems, fixes or improvements please refer to the discussions section.

Before creating a pull request, make sure to open an issue first.

Committing your changes, fixes or improvements in a new branch with documentation will be appreciated.

Back to top

You might also like...
VELOX - The fastest way to build simple websites using PHP!
VELOX - The fastest way to build simple websites using PHP!

VELOX The fastest way to build simple websites using PHP! Table of Contents Installation About VELOX Architecture Config Classes Functions Themes Chan

The Laravel Lumen Framework.

Lumen PHP Framework Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe d

Slim Framework 4 Skeleton Application

Slim Framework 4 Skeleton Application Use this skeleton application to quickly setup and start working on a new Slim Framework 4 application. This app

Silly CLI micro-framework based on Symfony Console

currentMenu home Silly CLI micro-framework based on Symfony Console. Professional support for Silly is available via Tidelift Video introduction in fr

⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.
⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.

Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP. 💧 Files and functions as first-class citi

A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery.

PHP Netflix Eureka Client A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery. Installation You can install this package

Yet another PHP Microframework.

ρ Yet another PHP Microframework. The premise of this framework is to be backwards-compatible (PHP = 5.6) with powerful utilities (Like caching and l

Modern CMS with shop features based on fullstack symfony and sylius components

The enhavo CMS is a open source PHP project on top of the fullstack Symfony framework and uses awesome Sylius components to serve a very flexible soft

Fullstack komponents to write Forms, Queries and Menus in Laravel

kompo.io • Documentation • Demos • Twitter kompo/kompo kompo/kompo is a library of Fullstack Komponents to help you write forms, queries and menus in

Interview project for Fullstack Developer.

Interview Project Fullstack Requires PHP: 7.0 WP requires at least: 5.7 WP tested up to: 5.7 WC requires at least: 5.6.0 WC tested up to: 5.8.0 Stable

Desafio prático para desenvolvedores fullstack que desejam entrar para nosso time.

Instruções para realizar os exercícios Essa avaliação é composta por três partes, que visam servir de base para análise das competências dos candidato

Sample Content - PHP Retriever - Simple MVC Front Controller Mini Framework

### PHP-RETRIEVER AND SAMPLE CONTENT | SIMPLE MVC FRONT CONTROLLER MINI FRAMEWORK Version: 0.2 License: GPLv3 or later Requires at least: PHP 7.3+ Co

MINI is an extremely simple and easy to understand skeleton PHP application
MINI is an extremely simple and easy to understand skeleton PHP application

MINI MINI is an extremely simple and easy to understand skeleton PHP application, reduced to the max. MINI is NOT a professional framework and it does

Larasymf - mini framework for medium sized projects based on laravel and symfony packages

Larasymf, PHP Framework Larasymf, as its says is a mini framework for medium sized projects based on laravel and symfony packages We have not yet writ

A Rich Featured Mini PHP MVC Framework

Footup MVC PHP Framework Un mini framework MVC PHP qui comporte : CLI support for generating class Translation support Config using PHP File or .env (

A simple mini pos that handles managing product data's and product categories

What is CodeIgniter CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP. Its goal is to enable

mini Project in Laravel and vue js. Real World Laravel 8x + vue js Dashboard.Task management and project management system
mini Project in Laravel and vue js. Real World Laravel 8x + vue js Dashboard.Task management and project management system

mini Project in Laravel and vue js. Real World Laravel 8x + vue js Dashboard.Task management and project management system. Dashboard features such as: Complete Dashboard, Custom Authentication, Email Verification, custom-login-register-forgot password (without jetstream).

Collection of useful PHP functions, mini-classes, and snippets for every day.

JBZoo / Utils Collection of PHP functions, mini classes and snippets for everyday developer's routine life. Install composer require jbzoo/utils Usage

Collection of PHP functions, mini classes and snippets for everyday developer's routine life

JBZoo / Utils Collection of PHP functions, mini classes and snippets for everyday developer's routine life. Install composer require jbzoo/utils Usage

Releases(v1.0.1)
  • v1.0.1(Nov 23, 2021)

  • v1.0.0(Nov 17, 2021)

    First release of the mini framework StackSync featuring :

    • Custom API system.
    • Middleware.
    • Token authentication (JWT).
    • Migrations & Seeding.
    • Flexible routing.
    • Components based views.
    • PSR-4 autoloading.
    • Custom script commands for file generation and various operations.
    Source code(tar.gz)
    Source code(zip)
Owner
Khomsi Adam
Junior Fullstack Web developer.
Khomsi Adam
🐺 Lightweight and easy to use framework for building web apps.

Wolff Web development made just right. Wolff is a ridiculously small and lightweight PHP framework, intended for those who want to build web applicati

Alejandro 216 Dec 8, 2022
ExEngine is an ultra lightweight micro-services framework for PHP 5.6+

ExEngine is an ultra lightweight micro-services framework for PHP 5.6+. Documentation Checkout the Wiki. Examples Click here to browse examples, also

linkfast.io 1 Nov 23, 2020
Lemon is php micro framework built for simple applications.

Lemon is simple micro framework that provides routing, etc.

Lemon 20 Dec 16, 2022
Blink is a micro web framework for building long-running and high performance services

Blink is a micro web framework for building long-running and high performance services, the design heavily inspired by Yii2 and Laravel. Blink aims to provide the most expressive and elegant API and try to make the experience of web development as pleasant as possible.

Jin Hu 837 Dec 18, 2022
[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components

Silex, a simple Web Framework WARNING: Silex is in maintenance mode only. Ends of life is set to June 2018. Read more on Symfony's blog. Silex is a PH

Silex 3.6k Dec 22, 2022
A resource-oriented micro PHP framework

Bullet Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by par

Vance Lucas 415 Dec 27, 2022
TidyPHP is a micro php framework to build web applications

TidyPHP is a micro MVC PHP Framework made to understand how PHP Frameworks work behind the scense and build fast and tidy php web applications.

Amin 15 Jul 28, 2022
PHP微服务框架即Micro Service Framework For PHP

Micro Service Framework For PHP PHP微服务框架即“Micro Service Framework For PHP”,是Camera360社区服务器端团队基于Swoole自主研发现代化的PHP协程服务框架,简称msf或者php-msf,是Swoole的工程级企业应用框

Camera360 1.8k Jan 5, 2023
Frankie - A frankenstein micro-framework for PHP

Frankie - A frankenstein micro-framework for PHP Features Frankie is a micro-framework focused on annotation. The goal is to use annotation in order t

null 19 Dec 10, 2020
REST-like PHP micro-framework.

Phprest Description REST-like PHP micro-framework. It's based on the Proton (StackPhp compatible) micro-framework. Phprest gives you only the very bas

Phprest 312 Dec 30, 2022