Download the PHP package codemini/framework without Composer
On this page you can find all versions of the php package codemini/framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codemini/framework
More information about codemini/framework
Files in codemini/framework
Package framework
Short Description Mini framework PHP for small applications - Create fastly website or system with standard MVC structure
License MIT
Homepage https://github.com/fabriciopolito/Codemini
Informations about the package framework
Codemini
Mini PHP framework - Create quickly application with standard MVC structure.
Leia na versão em português (pt-BR): Português pt-BR
Why use Codemini?
If you don't want to use a complex structure due to any reasons and don't want being tied down it, so Codemini is option for you.
Codemini is very simple to use, you can run your projet in public
folder like Laravel, CodeIgniter 4 or if you are using shared host, just copy index.php
and .htaccess
from public folder into root folder and all things going to work well.
You can use easily other packages from Packagist.org into your project, just run composer require <vendor>/<package>
and Codemini will understanding all packages that you have installed.
Third party tools like WAMP or XAMPP
As i sad above, if you are using shared host or using tools like WAMP or XAMPP, just copy index.php
and .htaccess
from public folder into root folder and all things going to work well.
Example:
- Copy your project folder into
www
orhtdocs
- Copy
index.php
and.htaccess
from public folder into root folder
Note: Remove public folder if you want
Why do it?
Because when you are using tools like WAMP or XAMPP, the DocumentRoot of Apache is point to root folder www (WAMP) or htdocs (XAMPP) and not to public folder of framework.
This rule is valid not only for Codemini but CodeIgniter 4, Laravel etc. It is the way the frameworks works.
Requirements
- Codemini works with PHP 5.4+. :heavy_check_mark:
Project structure
- cli-tools
- codemini_tests.sql
- composer.json
- LICENSE
- app/
- Controllers/
- Models/
- Views/
- Config.php
- Constants.php
- Connection.php
- Init.php
- public/
- .htaccess
- index.php
- src/
- Core/
- Bootstrap.php
- Common.php
- Controller.php
- Model.php
- Request.php
- Libraries/
- Input.php
- Redirect.php
- Session.php
- Validator.php
- Core/
Installation
With Composer Creating Project
1 - If you want to install as composer project, run: composer create-project --prefer-dist codemini/framework name-folder-of-you-project
2 - Open terminal and run cli-tools: php cli-tools serve
Optional: Run with PHP built-in server, go to public
folder and run: php -S localhost:8080
Note: In this case it is not necessary to run composer install because the composer create-project already do it for you.
With Github
1 - If you want to install with Git clone, run: git clone https://github.com/fabriciopolito/Codemini.git
or download "Download ZIP" and extract files.
2 - Run Composer (required) in root project folder where contain composer.json to create autoload files.
- If you have installed Composer globally:
composer install
- If you have composer.phar:
php composer.phar install
3 - Open terminal and run cli-tools: php cli-tools serve
Optional: Run with PHP built-in server, go to public
folder and run: php -S localhost:8080
Your index.php should looks like this:
Configuration
Note: Codemini does not has many configurations.
Modify standards files:
- app /
Config.php
- Define config to base_url, mysql, environment, timezone etc
Example:
Note: the file app/Config.php has full documentation each option
-
app /
Constants.php
- Define your project name and files location... and create yours Controllers, Views and Models !
Using Controller, Models and Views
Creating Controller
Controllers / Home.php
- With cli-tools:
php cli-tools create-controller Home
Output: ./app/Controllers/Home.php
Creating Views
Views / Template/index.phtml
Creating Models
Models / Products.php
- With cli-tools:
php cli-tools create-model Products
Output: ./app/Models/Products.php
Helper Functions
-
configItem('key')
return the config specified name. Example: `` &getInstance()
return controller object instance
Libraries
How to use librarie in Controller?
It is very simple!
Just load it with use
instruction and the librarie will be available for you.
Example:
The basic libraries of Codemini
Input
- Help you to manipulate get, post, fileecho Input::get('email')
echo Input::post('email')
echo Input::file('userfile')
echo Input::all()
Redirect
- Redirect user to other locationecho Redirect::to(configItem('base_url') . 'login/index')
Session
- Help you to manipulate session dataSession::start()
Session::set('logged_in', true)
Session::set(array('user_id' => 1, 'logged_in' => true))
Session::get('user_id')
Session::has('logged_in')
Session::all()
Session::id()
Session::regenerateId()
Session::remove('user_id')
Session::destroy()
Validator
- Help you validate dataValidator::getErrors()
Validator::getMsg()
Validator::setOpenTag('<p>')
Validator::setCloseTag('</p>')
Validator::required($val)
Validator::isEmail($val)
Validator::isUrl($val)
Validator::isFloat($val)
Validator::isInt($val)
Validator::isBool($val)
Validator::isIp($val)
Validator::regex($val, '/[a-z]/i')
Note: The libraries has full documentation in each option.
Do you want to create other folders and files?
You are free!
So example, create a folder Helpers
in ./app/
and a file Upload.php
and the only thing you have to do is set the properly namespace for autoloading.
Example ./app/Helpers/Upload.php
:
And then use it in any controller this way:
Example ./app/Controllers/Home.php
Do you want to use other components from Packagist?
It is very simple! Just run Composer require command and load it the same way above.
Example 1: composer require plasticbrain/php-flash-messages
Example 2: composer require monolog/monolog
Author
Fabricio Pólito - https://github.com/fabriciopolito
Thanks using it :+1:
License
Codemini is licensed under the MIT License :heavy_check_mark: