Important PHP & CMD Command

 Important PHP & CMD Command


#Terminal

#To start xmpp in linux:

/opt/lampp$ sudo /opt/lampp/./manager-linux-x64.run


#if not starting:

sudo service mysql stop

sudo /etc/init.d/apache2 stop

sudo /opt/lampp/lampp start



#to stop xampp

sudo /opt/lampp/lampp stop


#Change Access of file/folder in Ubuntu:

1. chmod -R 777 /path/to/folder: change permission of all files and subdirectories within the this directory.

2. chmod 777 /path/to/folder: only the this directory permission will be changed, but not its subdirectories or files.


400 -Read only

777 -all can read/write/execute (full access)

755 -owner can read/write/execute, group/others can read/execute.


#PHP & Laravel


#Create project in laravel:

composer create-project laravel/laravel project_name


#clear all cache:

php artisan optimize

php artisan optimize:clear



#if facing any problem (local fine but after pull facing problem on live) then:

composer dump-autoload --ignore-platform-reqs

composer update --ignore-platform-reqs

php artisan optimize:clear

php artisan cache:clear


#get all route list:

php artisan route:list



#laravel if else

$get = $status ? 0 : 1;


in blade file:

{{ $product->status==0 ? 'bg-light':'bg-dark' }}



#Make route to clear cache

Route::get('/clear-cache', function() {

   Artisan::call('cache:clear');

   Artisan::call('config:clear');

   Artisan::call('route:clear');

   Artisan::call('view:clear');

   Artisan::call('optimize:clear');

   return "Cache is cleared";

});


#Create Dummy data in Laravel:

use command line-

php artisan tinker

User::factory()->count(30)->create()

User::factory(10)->create()

make another factory:

php artisan make:factory PostFactory

Post::factory(10)->create()


#Solution of "Vite manifest not found":

1. composer require laravel/breeze

2. php artisan breeze:install


#If reset password not working, giving error: "Call to undefined function mb_strcut()":

  1. sudo apt-get install php8.2-mbstring

(php version will be changed accordingly)



Post a Comment

0 Comments

Visual Studio