Skip to content

MediaSoftDev/BECKY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BECKY

Description

This is a software of application. Becky v.1 Framework with PHP using the Pattern MVC.

Installation

Using PHP 7 preferably.

DataBase

Using MYSQL preferably.

Usage

$ git clone https://github.com/DanielArturoAlejoAlvarez/BECKY.git [NAME APP]

Follow the following steps and you're good to go! Important:

alt text

Coding

Connection DB

...
function __construct(){
            try{
                $this->dbh = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->dbName, $this->user,$this->pass);
                $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            }catch(PDOException $e){
                $this->error=$e->getMessage();
                echo $this->error;
            }
        }
...

Libraries

...
function __construct(){    
    $url=$this->get_url();          
    if(file_exists('../app/controllers/' .ucwords($url[0]). '.php')){
        $this->current_controller=ucwords($url[0]);
        unset($url[0]);
    }
    require_once "../app/controllers/" .$this->current_controller. ".php";    
    $this->current_controller=new $this->current_controller;    
    if(isset($url[1])){
        if(method_exists($this->current_controller, $url[1])){
            $this->current_method=$url[1];
            unset($url[1]);
        }
    }
    $this->params=$url ? array_values($url) : [];
    call_user_func_array([$this->current_controller, $this->current_method], $this->params);
}
...

Models

...
class User{
        private $db;
        function __construct(){
            $this->db=new Base();
        }

        public function getUsers(){
            $this->db->query("SELECT * FROM users");
            return $this->db->getRows();
        }
    }
...

Controllers

...
public function index(){            
    
    $users=$this->user->getUsers();

    $data=[
        'title' =>  'Page Index',
        'users' =>  $users 
    ];

    $this->view('pages/index', $data);
...
}

Views

foreach($data['users'] as $user){
    echo $user->name;
}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/DanielArturoAlejoAlvarez/BECKY. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

Software of Application with PHP and MYSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published