PHP code example of parsgit / night
1. Go to this page and download the library: Download parsgit/night 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' );
parsgit / night example snippets
$all = input();
$name = input('name' );
$name = input('name' ,'default_value_if_not_exists' );
$name = get('name' ,'Default value' );
$name = post('name' );
$age = post('age' ,18 );
root_path();
public_path();
app_path();
storage_path();
views_path();
$app_path=app_path('Storage/text.txt' );
echo $app_path;
url();
url('account/login' );
$route=route_url();
$route=params_url();
$request = method();
if (isGet()){
}
if (isPost()){
}
namespace Controllers ;
class pageController {
function Action () {
return view('html_name' );
}
function idAction () {
$id=get('id' ,0 );
return $id;
}
}
$users=DB::select('select * from users where active=?' ,[true ]);
DB::insert('insert into users (name,age,username,password) values (?,?,?,?)' ,
[
'ben' ,
25 ,
'ben25' ,
Hash::create('123456' )
]);
DB::update('...' );
DB::delete('...' );
namespace Controllers ;
use App \Web \DB ;
class pageController {
function get_listAction () {
$pages=DB::table('page' )->get();
return $pages;
}
}
$user = DB::table('users' )->where('name' , 'John' )->first();
echo $user->name;
$user = DB::table('users' )->find(20 );
$first = DB::table('users' )
->whereNull('first_name' );
$users = DB::table('users' )
->whereNull('last_name' )
->union($first)
->get();
$count_users = DB::table('users' )->count();
$score = DB::table('users' )->sum(`score`);
$users = DB::table('users' )
->join('car' , 'users.id=car.user_id' )
->get();
$users = DB::table('users' )
->leftJoin('posts' , 'users.id=posts.user_id' )
->get();
$users = DB::table('users' )
->rightJoin('posts' , 'users.id=posts.user_id' )
->get();
$users = DB::table('users' )
->fullJoin('posts' , 'users.id=posts.user_id' )
->get();
$users = DB::table('users' )
->orderBy('name' , 'desc' )
->get();
$user = DB::table('users' )
->latest()
->first();
$randomUser = DB::table('users' )
->inRandomOrder()
->first();
$users = DB::table('users' )
->groupBy('account_id' )
->having('account_id' , '>' , 100 )
->get();
$users = DB::table('users' )
->groupBy('first_name' , 'status' )
->having('account_id' , '>' , 100 )
->get();
$users = DB::table('users' )
->duplicate('phone' , 2 )
->get();
$users = DB::table('users' )->skip(10 )->take(5 )->get();
$users = DB::table('users' )
->offset(10 )
->limit(5 )
->get();
DB::table('users' )->insert(
['email' => 'john@example.com' , 'votes' => 0 ]
);
DB::table('users' )
->where('id' , 1 )
->update(['votes' => 1 ]);
DB::table('users' )->increment('votes' );
DB::table('users' )->increment('votes' , 5 );
DB::table('users' )->decrement('votes' );
DB::table('users' )->decrement('votes' , 5 );
DB::table('users' )->delete();
DB::table('users' )->where('votes' , '>' , 100 )->delete();
DB::table('users' )->truncate();
namespace Controllers ;
use App \Web \File ;
class fileController {
function uploadAction () {
$upload=File::upload('myfile' );
}
}
$upload->path(public_path('imge' ));
$upload->toStorage('image/products' );
$upload->maxSize(250 );
$upload->maxSize(3 * 1023 );
$upload->limit_ext(['jpg' ,'png' ,'gif' ]);
$upload->limit_type(['image/jpage' ]);
$uplaod->rename('my_file_name' );
$uplaod->rename('my_file_name' ,'pngo' );
$upload->randomName();
$upload->save();
namespace Controllers ;
use App \Web \File ;
class fileController {
function uploadAction () {
$upload=File::upload('myfile' )
->limit_ext(['png' ,'jpg' ])
->maxSize(1024 )
->toStorage('image' )
->save();
if ($upload->status()==true ){
return ['upload' =>true ,'name' =>$upload->getFileName()];
}
else {
$errors=$upload->getErrors();
return ['upload' =>false ,'errors' =>$errors];
}
}
}
if ($upload->status()==true ){
}
$upload->getErrors();