September 7, 2022 in Php
For Laravel you need following server requirement
PHP >= 7.0.0
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
September 7, 2022 in Php
PHP >= 7.0.0
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
September 6, 2022 in Php
sudo apt update
sudo apt install --no-install-recommends php8.1
php -v
sudo apt install php8.1-fpm
sudo a2enconf php8.1-fpm
sudo apt-get install php8.1-PACKAGE_NAME
sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath
This command will install the following modules:
php8.1-cli – command interpreter, useful for testing PHP scripts from a shell or performing general shell scripting tasksphp8.1-common – documentation, examples, and common modules for PHPphp8.1-mysql – for working with MySQL databasesphp8.1-zip – for working with compressed filesphp8.1-gd – for working with imagesphp8.1-mbstring – used to manage non-ASCII stringsphp8.1-curl – lets you make HTTP requests in PHPphp8.1-xml – for working with XML dataphp8.1-bcmath – used when working with precision floatsphp -m
NOTICE: Not enabling PHP 8.1 FPM by default.
NOTICE: To enable PHP 8.1 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.1-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Processing triggers for libapache2-mod-php8.1 (8.1.9-1+ubuntu18.04.1+deb.sury.or g+1) ...
If wordpress website not working
sudo a2disconf php8.1-fpm
sudo a2dismod php7.4
sudo a2enmod php8.0
sudo service apache2 restart
August 7, 2022 in Laravel, Php
PHP 7.4 goes end of life (EOL) on the 28 November 2022 meaning known security flaws will no longer be fixed and sites are exposed to significant security vulnerabilities. It is important to update them to a newer version.
PHP 7.4, the next PHP 7 minor release, has been released for General Availability as of November 28th, 2019.
August 7, 2022 in Php
array_push() expects parameter 1 to be array, object given ?
August 7, 2022 in Php
$data = array();
$object = new stdClass();
$object->business_id= '';
$object->phone_number_id= '';
$object->recipient_phone_number= '';
$object->user_access_token= '';
$object->waba_id= '';
$object->version= '';
$data[0] = $object;
June 22, 2022 in Php
function delete_file($pFilename)
{
if ( file_exists($pFilename) ) {
// Added by muhammad.begawala@gmail.com
// '@' will stop displaying "Resource Unavailable" error because of file is open some where.
// 'unlink($pFilename) !== true' will check if file is deleted successfully.
// Throwing exception so that we can handle error easily instead of displaying to users.
if( @unlink($pFilename) !== true )
throw new Exception('Could not delete file: ' . $pFilename . ' Please close all applications that are using it.');
}
return true;
}
try {
if( delete_file('file_name') === true ){
echo 'File Deleted';
}
}
catch (Exception $e) {
echo $e->getMessage(); // will print Exception message defined above.
}
try {
if( file_exists($f) === true ){
if( @unlink($f) !== true )
throw new Exception('Could not delete file: ' . $f . ' Please close all applications that are using it.');
//echo 'File Deleted';
}
}
catch (Exception $e) {
echo $e->getMessage(); // will print Exception message defined above.
}
June 22, 2022 in Php
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
unlink("test.txt");
?>
June 22, 2022 in Php, Tips and Tricks
how to get and set value from and to from input text using jQuery when we have multiple input textbox in html
$('#example tfoot input[type="text"]').last().val($(this).val())
# HTML
<input type="text" name="quantity" value="1" class="input-text ">
<input type="text" name="quality" value="2" class="input-text ">
#jquery
$('[name]').first().val() // 1
$('[name]').last().val() // 2
June 22, 2022 in Laravel, Php, Ubuntu
RUN composer command in non root user
$ composer dump-autoload
RUN composer command in root user
# composer dump-autoload --no-plugins --no-scripts
if (User::where('phone', $input['phone'])->exists()) {
$success['result']=User::where('phone', $input['phone'])->whereRaw("updated_at >=('" . date('Y-m-d H:i:s') . "'-INTERVAL 60 SECOND) AND updated_at <='" . date('Y-m-d H:i:s') . "'")->exists();
if(!$success['result']){
$success['otp']=$otp;
$affectedRows = User::where('phone', $input['phone'])->update(array('otp' => $otp,'password'=>Hash::make($otp)));
}else { $isSend = 0; }
}else{
$success['result']=false;
$success['otp']=$otp;
$input['password'] = Hash::make($otp);
$input['otp']=$otp;
$user = User::create($input);
}
if($isSend)
{
$otp_response=json_decode($this->sendOtp($data,$otp));
$success['otp_response']=$otp_response->status;
//$otp_response->status == "success"
}