This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello guys. Thanks for a great work on October. I really like your CMS.
The question is how can I debug variables, db queries etc.?
What is the best practice to debug in October/Laravel?
I found TWIG dump and enabled it through https://github.com/octobercms/october/issues/278#issuecomment-47453739. It's working fine but I am looking for a better options - more details.
Something like "laravel-debugbar" https://octobercms.com/forum/post/explain-please-right-using-of-composer.
It would be great have a tutorial or something about debugging. It's almost the most important thing for newcomers.
Thank you
Last updated
xdebug. It's a pain to set up sometimes, but it's definitely the best way.
I've got it working with a Laravel install using Vagrant and PHPStorm, and it's fantastic for stepping through lines of code. Once I've got it working with October on a different machine I'll post some information. I appear to have missed a step with that Vagrant box so it's not ready yet.
barryvdh/laravel-debugbar
is fantastic tool
- Add
"barryvdh/laravel-debugbar": "1.*"
to yourcomposer.json
in root folder. Note: If this file is missing in your project you should copy that from october repo and some other missing files like .gitignore and others - Do
composer update
- After updating composer, add the ServiceProvider to the providers array in app/config/app.php
'Barryvdh\Debugbar\ServiceProvider',
- You need to publish the assets from this package
php artisan debugbar:publish
- Add the following entry into the return array for
getFunctions()
new Twig_SimpleFunction('dump', ['\Barryvdh\Debugbar\Facade', 'info'], ['is_safe' => ['html']]),
in
modules/cms/twig/Extension.php
- Paste in your twig template
{{ dump(your_variable) }}
Imgur - Refresh page Imgur
Note: After updating octobercms core you should repeat step 5
Last updated
I think it's better convert it to plugin as daftspunk suggested, because after october:update it doesn't locate debugbar's provider, so I need to do composer update
I followed the steps above to add the debugbar but it failed when running php artisan debugbar:publish
PHP Fatal error: Class 'Barryvdh\Debugbar\ServiceProvider' not found in /vagrant/mbtassino/vendor/laravel/framework/src
/Illuminate/Foundation/ProviderRepository.php on line 158
PHP Stack trace:
PHP 1. {main}() /vagrant/mbtassino/artisan:0
PHP 2. require_once() /vagrant/mbtassino/artisan:30
PHP 3. require() /vagrant/mbtassino/bootstrap/start.php:57
PHP 4. Illuminate\Foundation\ProviderRepository->load() /vagrant/mbtassino/vendor/laravel/framework/src/Illuminate/Fou
ndation/start.php:210
PHP 5. Illuminate\Foundation\ProviderRepository->compileManifest() /vagrant/mbtassino/vendor/laravel/framework/src/Ill
uminate/Foundation/ProviderRepository.php:58
PHP 6. Illuminate\Foundation\ProviderRepository->createProvider() /vagrant/mbtassino/vendor/laravel/framework/src/Illu
minate/Foundation/ProviderRepository.php:122
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Barryvdh\\Debugbar\\Servi
ceProvider' not found","file":"\/vagrant\/mbtassino\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/ProviderRe
pository.php","line":158}}
Last updated
Another way. Put it on app/start/global.php
or bootstrap/start.php
\System\Classes\MarkupManager::instance()->registerCallback(function($manager){
$manager->registerFunctions([
'dump' => function($param){
return \Debugbar::info($param);
},
]);
});
Put in on twig file:
{{ dump('test') }}
@emzero439
do composer update
after php artisan october:update
Related https://github.com/octobercms/october/issues/456
NOTE: in my case I need to do rm -r vendor/composer
before composer update
Last updated
Hey guys, I added some extensions for laravel-debugbar to my projects, to replace the dump function and add a stopwatch tag. It's in dev-master for now, is that helpful for you? See https://github.com/barryvdh/laravel-debugbar/blob/master/readme.md#twig-integration
Let me know if I can do something to help. (Not a October user myself)
Cool. You could consider registering the 2 Twig extensions in your Plugin also, if you want access to the dump
function and stopwatch
tag.
Thanks for the tip, @barryvdh2622. I'll add them tomorrow. One other thing, can you somehow allow your debugbar:publish
command to take a path argument? October doesn't support a top level packages directory. I'd also then need a config option for the asset directory (defaulting to what you have at the moment) so that the URLs output in HTML source by your plugin point to the correct location.
I'd like to be able to publish to an assets directory in my plugin or some other public directory automatically on plugin installation. At the moment as you can see from this monstrosity I'm just str_replace
ing the path you output to HTML source with your packages original asset locations. It's very ugly and prone to errors if you change things around in future.
Last updated
Hmm, I noticed. I also saw that Middleware doesn't work, so perhaps I could add a check for that too. Any idea's what would be the best way to detect that? Does October has some specific version/constant I can check?
@barryvdh2622 The twig extensions have been added and will be available and working as soon as my PR is merged.
As for an october-specific constant, I'm not sure. You'd have to ask SamuelGeorges/daftspunk in the #october IRC room or get very lucky and have him grace us with his presence on the forum here :)
Last updated
Hi Flynsarmy The debugbar works great thanks (and should be a proper published plugin when the PR comes through of course). The only part of it that I cant see any output for is the twig dump() command which does not error it just does nothing. The stopwatch command is working fine, as are the debugbar:: commands. Any suggestions?
Adding {{ dump(this) }}
works fine on my layout. Not sure what your problem could be. Try hitting save again - I've noticed sometimes October will serve up a cached copy of the page until you resave your page/partial/layout.
Other than that the usual - check your error logs. I take it you implimented my patch manually? Because I didn't think the update had been released to the public yet.
EDIT: Also the reason the plugin isn't on the marketplace is because it requires in an entire Laravel distro bloating it up to a 12MB plugin. Sam understandably doesn't want that and I don't want to fork it and copy just the required folders in because that messes with my workflow.
Last updated
Yes I implemented manually and stopwatch works so I dont think that is the problem.
I have tried it in an October page through the backend and added it to a partial in a plugin. No luck in either.
Oh well I can live without it, I needed the Debugbar:: commands for debugging ajax stuff for which it is great.
@barryvdh2622 Could you please remove the //# sourceMappingURL=jquery.min.map
line from the bottom of your src/DebugBar/Resources/vendor/jquery/dist/jquery.min.js file? You don't include a map file in that same directory so it results in a 404 on every page load.
Last updated