Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Laravel Error “php artisan serve” Command: ‘php’ is not recognized


Title: Troubleshooting “php artisan serve” Command: ‘php’ is not recognized

Introduction: Running into the error “The term ‘php’ is not recognized as the name of a cmdlet, function, script file, or operable program” when trying to use the php artisan serve command in Laravel can be frustrating. This issue is commonly encountered on Windows systems, and it is typically due to the PHP executable not being recognized in the system environment.

php : The term 'php' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ php artisan serve
+ ~~~
    + CategoryInfo          : ObjectNotFound: (php:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
  1. PHP not in the System PATH:
    • The PHP executable is not added to the system’s PATH variable, preventing the command prompt from recognizing the ‘php’ command.

Solution:

Option 1: Add PHP to the System PATH

Step 1: Find PHP Installation Directory

  • Locate the directory where PHP is installed. Common paths include C:\xampp\php or C:\wamp\bin\php\phpx.x.x.

Step 2: Add PHP to the System PATH

  • Right-click on “This PC” or “Computer” on your desktop or in File Explorer.
  • Select “Properties.”
  • Click on “Advanced system settings” on the left.
  • Click the “Environment Variables” button.
  • In the “System variables” section, select the “Path” variable, then click “Edit.”
  • Click “New” and add the path to the PHP executable (e.g., C:\xampp\php).

Step 3: Open a New Command Prompt

  • Close any existing command prompt windows and open a new one to apply the changes.

Step 4: Retry the Artisan Command

  • Run php artisan serve again in the command prompt.

Option 2: Use the PHP Executable Directly

Step 1: Use Full Path to PHP Executable

  • Run the php artisan serve command with the full path to the PHP executable:
"C:\xampp\php\php.exe" artisan serve

Replace "C:\xampp\php\php.exe" with the actual path to your PHP executable.

After this you still getting the same error then check your composer. If there is no composer then install composer

More topics:

1How to download and installer php and How to add path in apace and vhost
2How to make a partition in Windows 11 from C drive
3How to do file-level commenting
4Uncaught Error: Syntax error, unrecognized expression: #
5Error: Argument 1 passed to App\…\UploadQuoteRequestFileTestOnly() must be as instance of Illuminate\Http\Request
6List of My Blogs of Oct
7Responsive Layout using Media Queries
8Flutter Error: Fix this issue by adding …compileSdkVersion 33
9Flutter: SDK Version solving failed
10Flutter Project Creating issue (is not a valid Dart package name)
11Flutter: Please correct the pubspec.yaml file at :\Users\…\pubspec.yaml
12Error: MainActivity.java is not on the classpath of project app, only syntax errors are reported
13showing Error on phpMyAdmin “No space left on device”
14How to use various types of comments
15Error: HTTP 500 Internal Server”Illuminate\Http\Resources\Json\Resource” not found
16Error: Call to undefined function str_slug()
17write of 2225 bytes failed with errno=28 no space left on device
18What is use of @yield @extend @section in Laravel
19Resolving FatalError: Trait “Illuminate\Foundation\Auth\AuthenticatesUsers” not found
20Error: “Object of class GuzzleHttp\Psr7\Response could not be converted to string”Error:
21401 Unauthorized response
22Resolving Laravel Passport and GuzzleHTTP Version Conflict
23Managing Outdated Dependencies in Laravel with Composer
24Resolving Composer Dependency Conflict: Laravel Passport and GuzzleHTTP
25Resolving PHPUnit Dependency Conflict: PHP Version Mismatch
26Updating Laravel TrustProxies Middleware after Framework Version Upgrade
27Troubleshooting Laravel: “laravel.EMERGENCY: Unable to create configured logger. Using emergency logger.”
28Resolving SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘provider’ in ‘field’
29Error: In order to use the Auth::routes() method, please install the laravel/ui package
30Resolving SQLSTATE[42S22] Error in Laravel Passport Upgrade

Related Posts

Master DevOps with the Best Free Tutorials Online

The demand for DevOps professionals is skyrocketing as organizations rapidly adopt modern development and deployment methodologies. Whether you are a beginner looking to enter the DevOps space…

Error in Laravel:”Invalid Key Supplied”

while trying to log in to your Laravel application, don’t worry. This issue is commonly related to misconfigured or missing keys for Laravel Passport’s OAuth2 authentication system….

Error in Laravel “Davmixcool\MetaManager\MetaServiceProvider Not Found”

When working on Laravel projects, developers often encounter errors during the setup or runtime process. One such error is the “Class ‘Davmixcool\MetaManager\MetaServiceProvider’ not found”, which can occur…

Discover Rewa Effortlessly with Motoshare’s Convenient Bike and Car Rentals

Rewa, the “Land of White Tigers,” offers a unique blend of historical, cultural, and natural attractions that captivate every traveler. To make exploring this charming city more…

Discover Shimoga (Shivamogga) Effortlessly with Motoshare’s Bike and Car Rentals

Nestled in the lush greenery of Karnataka, Shimoga (Shivamogga) is a haven for nature lovers and history enthusiasts. From the roaring Jog Falls to the tranquil forests…

Explore the Spiritual Charm of Mathura with Motoshare’s New Bike and Car Rental Services

Mathura, the birthplace of Lord Krishna, is a city brimming with spirituality, vibrant culture, and historical significance. To make your journey through this sacred city seamless, Motoshare…

4 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x