【第一篇】Laravel12安装
1. First, install Composer (if you haven't already)
Laravel uses Composer for installation. Make sure you have Composer installed:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" sudo mv composer.phar /usr/local/bin/composer
2. Install the Laravel installer globally via Composer
composer global require laravel/installer
3. Add Composer's global bin directory to your PATH
The Laravel executable is installed in Composer's global bin directory. You need to ensure this is in your PATH.
For macOS/Linux:
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
4. Now try creating a new Laravel project again
laravel new example-app
Alternative: Create project directly via Composer
If you still have issues with the Laravel installer, you can create a new project directly with Composer:
composer create-project laravel/laravel example-app
This should resolve the "command not found" error and allow you to create new Laravel projects.
评论区