Giter Club home page Giter Club logo

strukt-framework's Introduction

Strukt Framework

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

The is the package that unifies all strukt-strukt components under the framework.

Rarely should anyone use this on its own.

Getting started

echo {"minimum-stability":"dev"} > composer.json
composer require "strukt/framework:1.1.7-alpha" --prefer-dist

Setup, Cache, Configuration & Environment

Cache

Always remember to clear and reload the cache when necessary

./xcli cache:clear 
./xcli cache:make cli
./xcli cache:make idx

Shell

Drop into shell

./xcli shell:exec

Setting Application Type

config("app.type", "App:Idx")// for index.php, alternative App:Cli for console

Configuration

config("facet.middlewares")
config("facet.providers")

Environment Setup

This class is defaultly found in strukt-commons

Strukt\Env::withFile();//default .env file in your root folder
Strukt\Env::withFile(".env-dev");
Strukt\Env::set("root_dir", getcwd());//custom environment variable
Strukt\Env::get("root_dir");

Setup Packages Registry

File location ./cfg/repo.ini

repos(); //list all repositories
repos("published");//list all published strukt packages
repos("installed");//list all installed strukt packages

Packages

Default Package

$core = new Strukt\Package\Core();//implements Strukt\Package\Pkg

//returns array of middlewares, commands and providers
$core->getSettings($type);//type is "App:Idx" or "App:Cli"

$core->getName();//core
$core->getCmdName();//null
$core->getFiles();//null
$core->getModules();//null
$core->isPublished();//true by default
$core->getRequirements();//null or array

The above methods are in abstract class Strukt\Package\Pkg you can use them to create your package.

Building Packages

Your first step in developing your package will require you to install strukt-framework and execute composer exec strukt-cfg command that will create your folder structure. You'll need to create src and package folders.

See structure of package below.

├── bootstrap.php
├── cfg
├── console
├── index.php
├── lib
├── tpl
├── vendor
├── composer.json
├── LICENSE
├── package #Place all your packages files here
├── README.md
└── src
    └── Strukt
        └── Package
            └── Pkg{{Package Name}}.php #Identify your package resources here

Your package class in src/Strukt/Package/Pkg<Package Name>.php will have methods listed in the Default Package section that is it should implement the interface Strukt\Contract\Package

Package Autoloading

You may require to autoload libraries both from your root directory and package resources.

$loader = require "vendor/autoload.php";
...
...
$loader->addPsr4("App\\", [

	__DIR__."/lib/App",
	__DIR__."/package/lib/App"
]);

return $loader;

Note

For packages that require installation into your app/src/{{AppName}} folder, there are a few tricks you could use while building your package. The publish:package command takes argument package for publishing packages that are currently in development, since your source will be in the root folder in a subfolder called package.

This will require you to enter into your cfg/repo.php (See Setup Packages Registry) and indicate your currently in-development package with the key/keyword package which will allow the publisher to install files in the your app source folder app/src.

Validator

Example

class User extends \Strukt\Contract\Form{

	/**
	* @IsNotEmpty()
	* @IsAlpha()
	*/
	public string $username;

	/**
	* @IsNotEmpty()
	*/
	public string $password;
}

Validator Annotations

/**
* @IsNotEmpty()
* @IsAlpha()
* @IsAlphaNum()
* @IsNumeric()
* @IsEmail()
* @IsDate(Y-m-d)
* @IsIn(a,b,c)
* @EqualTo(xyz)
* @IsLen(10)
*/

Adding Validators

New validators can be added is in your lib/App/Validator.php There you can find an example App\Validator::isLenGt

/**
* @IsLenGt(10)
*/

strukt-framework's People

Contributors

pitsolu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.