在 Debian 上调试 Laravel 项目,通常可以从环境检查、日志、错误显示、调试工具、Xdebug几个方面入手。下面给你一套比较实用的流程。
php -v
Laravel 对 PHP 版本有要求(如 Laravel 10 需要 PHP 8.1+)
php -m | grep -E "mbstring|xml|curl|json|sqlite|pdo|openssl"
缺失可安装:
sudo apt install php-mbstring php-xml php-curl
composer -V
.envAPP_ENV=local
APP_DEBUG=true
php artisan config:clear
php artisan cache:clear
tail -f storage/logs/laravel.log
# PHP
tail -f /var/log/php*-fpm.log
# Nginx
tail -f /var/log/nginx/error.log
# Apache
tail -f /var/log/apache2/error.log
dd() / dump()dd($variable);
// 或
dump($variable);
php artisan 排错php artisan route:list
php artisan migrate:status
php artisan config:show
php artisan tinker
可直接测试模型、查询:
App\Models\User::first();
sudo apt install php-xdebug
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
重启 PHP:
sudo systemctl restart php*-fpm
launch.jsonsudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache
try_files $uri $uri/ /index.php?$query_string;
php artisan schedule:list
crontab -e
* * * * * cd /path && php artisan schedule:run
✅ APP_DEBUG=true
✅ 日志能看
✅ 权限正确
✅ PHP 扩展齐全
✅ Xdebug 可用
如果你愿意,可以告诉我:
我可以直接帮你精准定位问题。