mardi 2 mars 2021

What is the best practice to use Constants in Laravel that leverage syntax checking in VS Code?

I am aware there are already a lot of answers being posted on best practices of using Constants in Laravel. I come from the Java world whereby constants are checked for validity in the editor. In Laravel, using the config/constants.php method,

return [
    'options' => [
        'balance_outstanding' => 0,
        'balance_balance' => 1,
        'balance_partial_balance' => 2,
    ] 
];

Whereby we refer to the constant using Config::get('constants.options.balance_outstanding')) syntax, I cannot seem to trigger the syntax check nor autocomplete. It would be great if we can mouse over and see what the constant real value is. I am using https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client

So, my question is, what is the best way to define constants in such a way that the editor is smart enough to be aware that its a constant?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire