1. Go to this page and download the library: Download bhaswanth53/ynotphp 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/ */
// Define the namespace
namespace Models;
// use the DB Facade
use Facades\DB;
class User extends Model
{
public function model_function() {
// Add the query
}
}
$mail = new Mail();
// We can add multiple senders using the method.
$mail->addSender("[email protected]", "Sender Name");
$mail->addReceiver("[email protected]", "Receiver Name");
$mail->subject = "This is the subject";
// Body will look into mails folder inside views folder. The view file will execute is views/mails/view_name.php
$mail->body = "view_name";
// We can send arguments to the view file.
$mail->args = array(
"url" => "This is a url parameter",
"name" => "YNOTPHP"
);
try {
$mail->send();
return $this->back(); // It will return to the back page.
}
catch(Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
$get_data = $request->all("get") // Returns all data from get method.
$post_data = $request->all("post") // Returns all data from post method.
$ajax_data = $request->all("ajax") // Returns all data from ajax request.
public function encrypt() {
$string = "YNOTPHP";
// Encrypt string
$encrypted_string = Crypt::encrypt($string);
// Decrypt string
$decrypted_string = Crypt::decrypt($encrypted_string);
}
use Facades\File;
public function addimage()
{
// Create file instance
$file = new File();
// Get file by input name
$image = $file->get("image");
// Create a new name for the uploaded file.
// If you don't give any new name it will upload using its current name.
$name = "gallery_".time();
// Upload file
// $file->upload(file, path, new_name)
// If file has been uploaded, then it will return its name.
$name = $file->upload($image, "images", $name);
if($name)
{
// Uploaded successfully
}
else {
// Not uploaded
}
}
public function image() {
$file = new File();
$image = $file->get("image");
// $file->validateImageSizes(image, width(px), height(px))
if($file->validateImageSizes($image, 100, 250)) {
// Validation passed
} else {
// Validation fails
}
}
namespace Models;
use Facades\DB;
class Tag
{
public $table = "tags";
public function create($page, $tag)
{
// Open connection
$db = DB::open();
// Write query
$sql = "INSERT INTO tags (page, tag) VALUES (?, ?)";
// Execute query
$query = $db->stmt_init();
$query = $db->prepare($sql);
if($query)
{
$query->bind_param('is', $page, $tag);
$query->execute();
// Close connection
$query->close();
return true;
}
return false;
}
}