dimanche 29 janvier 2017

Laravel autoload file variable from view

I have recently move my projects into laravel. In my projects, I have a single file which contains common variables.
My common.php file is in app/Libs/common.php

$a = array(
  'b' => 'c'
);

I also added my common file is in composer.json file.
My composer.json file

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": { 
        "App\\": "app/"
    },
    "files": [
      "app/Libs/common.php"
    ]
},

Now I want to access this variable in view.
My View file:

<?php print_r($a); ?>

It gives me following errors:

Undefined variable a (View: ...)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire