Install the Bundle
Run composer require bmatzner/foundation-bundle:~5.5 and update AppKernel.php to include:
new Bmatzner\FoundationBundle\BmatznerFoundationBundle(),
Install Assets
Execute php app/console assets:install web (or --symlink for symlinked assets).
Include in Twig
Add the CSS and JS to your base template (base.html.twig):
<!-- CSS -->
<link rel="stylesheet" href="{{ asset('bundles/bmatznerfoundation/css/foundation.min.css') }}">
<!-- JS (after jQuery) -->
<script src="{{ asset('bundles/bmatznerjquery/js/jquery.min.js') }}"></script>
<script src="{{ asset('bundles/bmatznerfoundation/js/foundation.min.js') }}"></script>
Initialize Foundation Add a script tag to initialize Foundation components (e.g., dropdowns, tooltips):
<script>
$(document).foundation();
</script>
Use Foundation’s grid system in a Twig template:
<div class="row">
<div class="small-6 columns">Column 1</div>
<div class="small-6 columns">Column 2</div>
</div>
Asset Management
assets:install for production builds; leverage --symlink for development.web/bundles/bmatznerfoundation/ (prefer symlinks for updates).Component Initialization
$(document).foundation().$(document).foundation('reflow'); // For responsive updates
Twig Integration
{{ 'row'|foundation_class }}).{% block foundation_js %} in layouts to append JS snippets.Custom Sass Integration
vendor/bmatzner/foundation-bundle/Resources/public/scss/ to your project.app.scss:
@import "foundation/scss/foundation";
bmatzner/jquery-bundle is loaded before Foundation.data-abide or data-orbit attributes for interactive elements.form-control for inputs).Asset Paths
/bundles/bmatznerfoundation/) breaks when moving projects.{{ asset() }} or path() in Twig.JavaScript Conflicts
bmatzner/jquery-bundle and avoid global $ overrides.Dynamic Content
$(selector).foundation() after content loads.Sass Overrides
@import "foundation/variables"; first, then override.$(document).foundation('alert'); to test if Foundation is loaded.Custom Components
foundation.abide for form validation).foundation.min.js:
<script src="{{ asset('bundles/bmatznerfoundation/js/plugins.js') }}"></script>
Twig Extensions
// src/YourBundle/Twig/FoundationExtension.php
class FoundationExtension extends \Twig_Extension {
public function getFunctions() {
return [
new \Twig_SimpleFunction('foundation_grid', [$this, 'gridHtml']),
];
}
}
Configuration
config.yml (if the bundle supports it).foundation.min.js in production; debug with unminified versions.picturefill for responsive images.$(document).foundation('destroy'); to reset components in tests.How can I help you explore Laravel packages today?