1. Go to this page and download the library: Download jahwin/wecodefy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/* -----------------------------
* This is condition array, please don't change any key just add values
* This will be user if you want to redirect all route to the same controller function
* -----
* This condition will be good for Vue,Angular,React
* -----
* Let that framework to handle routes
* ----
* You can enable or disable this condition
* ------------------------------
*/
$route_condition = [
'ENABLED' => true,
'ALL_TO' => [
'folder' => 'site',
'return' => 'HomeController@index',
],
'EXCEPT' => ['/api','/admin'],
];
namespace app\middlewares;
use Pecee\Http\Middleware\IMiddleware;
use Pecee\Http\Request;
class AuthMiddleware implements IMiddleware
{
public function handle(Request $request): void
{
$user = "";
// If authentication failed, redirect request to 404 page.
if ( $user === null) {
responce("",404);
}
}
}
namespace app\controllers\[foldername];
use system\library\Controller;
class Home extends Controller
{
public function __construct()
{
parent::__construct();
}
public function welcome()
{
$data = array("name"=>"Hello world");
// Load template from `app/scheme/views/[folder_name]/home/index.twig`
return $this->render('folder name', 'home/index.twig', $data);
}
}
namespace app\models;
use system\library\Models;
use system\library\DB;
class User extends Models {
// This will allow to get all users in users table
public function getAllUser() {
$data = DB::table( 'users' )
->orderBy( 'id', 'desc' )->get();
return $data;
}
}
->after('column') //Place the column "after" another column (MySQL)
->autoIncrement() //Set INTEGER columns as auto-increment (primary key)
->charset('utf8') //Specify a character set for the column (MySQL)
->collation('utf8_unicode_ci') //Specify a collation for the column (MySQL/PostgreSQL/SQL Server)
->comment('my comment') //Add a comment to a column (MySQL/PostgreSQL)
->default($value) //Specify a "default" value for the column
->first() //Place the column "first" in the table (MySQL)
->nullable($value = true) //Allows (by default) NULL values to be inserted into the column
->storedAs($expression) //Create a stored generated column (MySQL)
->unsigned() //Set INTEGER columns as UNSIGNED (MySQL)
->useCurrent() //Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value
->virtualAs($expression) //Create a virtual generated column (MySQL)
$table->string('name', 50)->change(); // Change size of column
$table->string('name', 50)->nullable()->change(); // Change column to be nullable
$table->renameColumn('from', 'to'); // Rename column
$table->dropColumn('votes'); // Drop column
$table->dropColumn(['votes', 'avatar', 'location']); //Drop multiple columns from a table by passing an array of column names
$table->string('email')->unique(); // Create column with index
$table->index(['student_id', 'start_at']); // Create index on multiple columns you have created
$table->primary('id'); // Adds a primary key.
$table->primary(['id', 'parent_id']); // Adds composite keys.
$table->unique('email'); // Adds a unique index.
$table->index('state'); // Adds a plain index.
$table->dropPrimary('users_id_primary'); //Drop a primary key from the "users" table.
$table->dropUnique('users_email_unique'); //Drop a unique index from the "users" table.
$table->dropIndex('user_state_index'); //Drop a basic index from the "user" table.
$generate->word; // 'aut'
$generate->words($nb = 3, $asText = false); // array('porro', 'sed', 'magni')
$generate->sentence($nbWords = 6, $variableNbWords = true); // 'Sit vitae voluptas sint non voluptates.'
$generate->sentences($nb = 3, $asText = false); // array('Optio quos qui illo error.', 'Laborum vero a officia id corporis.', 'Saepe provident esse hic eligendi.')
$generate->paragraph($nbSentences = 3, $variableNbSentences = true); // 'Ut ab voluptas sed a nam. Sint autem inventore aut officia aut aut blanditiis. Ducimus eos odit amet et est ut eum.'
$generate->paragraphs($nb = 3, $asText = false); // array('Quidem ut sunt et quidem est accusamus aut. Fuga est placeat rerum ut. Enim ex eveniet facere sunt.', 'Aut nam et eum architecto fugit repellendus illo. Qui ex esse veritatis.', 'Possimus omnis aut incidunt sunt. Asperiores incidunt iure sequi cum culpa rem. Rerum exercitationem est rem.')
$generate->text($maxNbChars = 200); // 'Fuga totam reiciendis qui architecto fugiat nemo. Consequatur recusandae qui cupiditate eos quod.'
$generate->realText($maxNbChars = 200, $indexSize = 2); // "And yet I wish you could manage it?) 'And what are they made of?' Alice asked in a shrill, passionate voice. 'Would YOU like cats if you were never even spoke to Time!' 'Perhaps not,' Alice replied."
$generate->userAgent; // 'Mozilla/5.0 (Windows CE) AppleWebKit/5350 (KHTML, like Gecko) Chrome/13.0.888.0 Safari/5350'
$generate->chrome; // 'Mozilla/5.0 (Macintosh; PPC Mac OS X 10_6_5) AppleWebKit/5312 (KHTML, like Gecko) Chrome/14.0.894.0 Safari/5312'
$generate->firefox; // 'Mozilla/5.0 (X11; Linuxi686; rv:7.0) Gecko/20101231 Firefox/3.6'
$generate->safari; // 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_7_1 rv:3.0; en-US) AppleWebKit/534.11.3 (KHTML, like Gecko) Version/4.0 Safari/534.11.3'
$generate->opera; // 'Opera/8.25 (Windows NT 5.1; en-US) Presto/2.9.188 Version/10.00'
$generate->internetExplorer; // 'Mozilla/5.0 (compatible; MSIE 7.0; Windows 98; Win 9x 4.90; Trident/3.0)'
$generate->creditCardType; // 'MasterCard'
$generate->creditCardNumber; // '4485480221084675'
$generate->creditCardExpirationDate; // 04/13
$generate->creditCardExpirationDateString; // '04/13'
$generate->creditCardDetails; // array('MasterCard', '4485480221084675', 'Aleksander Nowak', '04/13')
// Generates a random IBAN. Set $countryCode to null for a random country
$generate->iban($countryCode); // 'IT31A8497112740YZ575DJ28BP4'
s$generate->wiftBicNumber; // 'RZTIAT22263'
$generate->fileExtension; // 'avi'
$generate->mimeType; // 'video/x-msvideo'
// Copy a random file from the source to the target directory and returns the fullpath or filename
$generate->file($sourceDir = '/tmp', $targetDir = '/tmp'); // '/path/to/targetDir/13b73edae8443990be1aa8f1a483bc27.jpg'
$generate->file($sourceDir, $targetDir, false); // '13b73edae8443990be1aa8f1a483bc27.jpg'
// get a random number between 10 and 20,
// with more chances to be close to 20
$generate->biasedNumberBetween($min = 10, $max = 20, $function = 'sqrt');
//Generate HTML document which is no more than 2 levels deep, and no more than 3 elements wide at any level.
$generate->randomHtml(2,3); // <html> content .... </html>
// Allow to add cookie
Cookies::add($key, $value, $day);
// Allow to get cookie
Cookies::get($key)
// Allow to delete cookie
Cookies::delete($key)
// Allow to check if cookie is enabled
Cookies::check()
// Allow to start session
Session::init();
// Allow to create session item
Session::add($key, $value);
// Allow to get session item
Session::get($key);
// Allow to delete session item
Session::delete($key);
// Allow to destroy all session
Session::destroy()
// Allow to add flashdata
FlashData::Add($key, $data);
// Get that data and get destroyed
FlashData::Get($key);
# output: /current-url
url();
# we check if the current url contains the `/api` part.
if(url()->contains('/api')) {
// ... do stuff
}
# Grab the query-string parameter id from the current-url.
$id = url()->getParam('id');
# Get the absolute url for the current url.
$absoluteUrl = url()->getAbsoluteUrl();