在 CentOS 环境下调试 Laravel,通常从「日志、错误显示、调试工具、运行环境」几个方面入手。下面按实用顺序给你一套常见做法。
php -v
composer -V
php artisan --version
.envAPP_DEBUG=true
APP_ENV=local
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
storage/logs/laravel.log
实时查看:
tail -f storage/logs/laravel.log
/var/log/php-fpm/error.log
# 或
/var/log/httpd/error_log
dump() / dd()dd($request->all());
php artisan route:list
php artisan tinker
composer require barryvdh/laravel-debugbar --dev
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
浏览器打开页面即可看到 SQL、请求、日志等信息。
yum install php-xdebug
# 或
pecl install xdebug
php.inizend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
chown -R nginx:nginx storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
setenforce 0
# 或
setsebool -P httpd_unified 1
.env 中 APP_DEBUG=truelaravel.logdd() 或 tinker如果你愿意,可以告诉我:
我可以直接帮你定位问题。