Hello, i make a custom library for enqueue my styles. What is the strategy to use this?
Strategy 1, in controller :
Code:
use App\Libraries\Enqueue;
$css = new Enqueue();
$css->load($arr);
But,the output will be html format
PHP Code:
<link href="style.css" rel="stylesheet" />
<link href="style2.css" rel="stylesheet" />
Or to strategy 2 , to load in every view ? In header.php and footer.php?But i once to set once....like globally
If i load in controller, how can i pass in view?I tried with :
Code:
use App\Libraries\Enqueue;
$css = new Enqueue();
$data = [
'css' => $this->css
];
echo view("footer",$data)
And in footer.php (also in header.php or any view where i need) i will iniziate this class:
PHP Code:
$css = new Enqueue();
$arr = myArray();
$css->load($arr);
But, i saw a little lazy loading on page....
I think i must to make my function to return an array, and after this i pass as variable array to viewer, and after to make a foreach...