Code Monkey home page Code Monkey logo

myyframework's Introduction

Myy php framework

php framework with advanced sql generation capabilities. With myyFramework you can make complex sql easily and fast and develop using a modular design with "get only what you need". Note: this this is currently a work in progress, see below for details for participation in the project. This project is intended to be used with PHP 7.3

To get started:

  1. Create a database (using heidi sql for instance) in mysql.
  2. Generate database schema mappings with console.php (examples in comments). Remember to set the config in apps/your-app-name/config/config.php

Some examples

Conroller class mapped to spesific paths

class site extends base_functions{
	
	private $calledAction;

	function __construct() {
		$this->type='site';
		$this->getLogic($this->type,__FUNCTION__);
	
	}

	public function site($language=null,$parameters=array()){
		require $this->getView($this->type,'index');

	}
	
	public function data($language=null,$parameters=array()){
		// $this->getLogic($this->type,__FUNCTION__);
		require $this->getView($this->type,'nextpage');
	
	}
	
	public function error($language=null,$parameters=array()){
	    require $this->getView($this->type,'error');
	}
	
	
}

Product logic class used in pathing classes to do the actual business logic

class productLogic extends Backend{
	
	public $product;
	public $cartProduct;

	public function main(){
		
		
	}

	public function getProduct($lang='en',$parameters=array(),$key=__FUNCTION__){
		if(isset($parameters['r'])){
			
				$id=$parameters['r'];
				$key.=$id;
				$data=$this->ds->getFromAPCu($key);
				
				// Simulate an update to a database with spesific tables
				// $this->ds->setUpdated(array('product','product_category')); exit;
				
				if($this->ds->isUpdated(array('product','product_category'),$key) || empty($data)){
					$qo=$this->ds->getSqlObject();
					$qo->selectColumns('product');
					$qo->selectColumns('product_category',array('product_category_name'));
					$qo->joinFrom('product','JOIN','product_category');
					$qo->where('product','product_id',array('=',$id));
					$this->product=$this->ds->queryDo($qo,true);
					$this->ds->setToAPCu($key,$this->product);
				}else if(!empty($data)){
					$this->product=$data;	
				}else{
					trigger_error("Error in APCu caching", E_USER_ERROR);
				}

				return true;
				
 		}else{
			return false;
		} 

	}

	public function getProductCart($lang='en',$parameters=array(),$key=__FUNCTION__){
			if(isset($parameters['r'])){
				$id=$parameters['r'];
				$key.=$id;
				$data=$this->ds->getFromAPCu($key);
				
				if($this->ds->isUpdated(array('product'),$key) || empty($data)){
					$qo=$this->ds->getSqlObject();
					$qo->selectColumns('product');
					$qo->where('product','product_id',array('=',$id));
					$this->cartProduct=$this->ds->queryDo($qo,true);
					$this->ds->setToAPCu($key,$this->cartProduct);
				}else if(!empty($data)){
					$this->cartProduct=$data;
				}else{
					trigger_error("Error in APCu caching", E_USER_ERROR);
				}
				
				return true;
				
			
			}else{
				return false;
			}

	}
	
	public function setProduct(){
		
		$so=$this->ds->getSqlQueryObject('sqlObject');
		
		
	}
	
	
}

View used to render and set the data from queries

<?php
namespace Framework;
if(Appdata::get('fReq')){
$title = "Test";
$metad = "Test";
require SNIPPLETS . 'head.php';
}
require SNIPPLETS.'menu.php';
?>
<div id="main">
	<div class="header">
		<h1>Hello world</h1>
		<h2></h2>
	</div>
	<div class="content">
		<?php 
		// foreach ($this->af->users as &$user) {
		//     echo $this->af->users["email"];
		//}
		?>
		<a href="http://localhost/data">Next page</a>
	</div>
</div>
<?php
if(Appdata::get('fReq')){require SNIPPLETS.'bottom.php';}

Simple query

$this->ds->q->selectColumns('user');
$this->ds->q->where('user','email',array('=','something'));
$this->users=$this->ds->queryDo(true);

A more complex query with caching

if($this->ds->isUpdated(array('product','product_category'),$key) || empty($data)){
	$qo=$this->ds->getSqlObject();
	$qo->selectColumns('product');
	$qo->selectColumns('product_category',array('product_category_name'));
	$qo->joinFrom('product','JOIN','product_category');
	$qo->where('product','product_id',array('=',$id));
	$this->product=$this->ds->queryDo($qo,true);
	$this->ds->setToAPCu($key,$this->product);
}else if(!empty($data)){
	$this->product=$data;	
}else{
	trigger_error("Error in APCu caching", E_USER_ERROR);
}

List of features

  • Database schema generation tool, generate.php in archetypes
  • Easy to create archetypes for project templating
  • Advanced SQL query generator with low footprint in terms of performance (works basically by constructing the query from blocks)
  • Modular structure: path, logic and view files. Simple but easy to use pathing system

List of unfinished features

  • Caching system finalizing.
  • ORM and Forms
  • Pagination
  • Translations
  • Automatic form generation tool
  • Sessions unfinished

myyframework's People

Contributors

lauri1010 avatar

Watchers

 avatar  avatar  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.