Are there any examples out there on how to integrate HTML5Boilerplate into Symfony? The problem that I'm running into is the way Symfony handles stylesheet and javascript loading.
Symfony likes you to add your stylesheets and javascript to a special object in the controller (or define them in the view.yml) and then your template/view just call <?php include_stylesheets() ?> and <?php include_javascripts() ?>.
The problem is that the HTML5Boilderplate template wants you to load the Modernizr.min.js in the <head> and all the rest of the javascript files at the end of the </body>. Symfony's magic function wants to just load them all at once though. And I can't seem to figure out a way to selectively load them one at a time in the template.
Also, HTML5Boilerplate has CDN jQuery loading with a dynamic local backup load like this:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jqduery.js"></script>
<script>window.jQuery || document.write("<script src='js/backend/libs/jquery-1.5.1.min.js'>\x3C/script>")</script>
Is there anyway to accomplish this in Symfony templates without having to inject the PHP $_SERVER[whatever] into the code?
I feel like I can probably make it all work together but I'm trying to avoid making it too hacky because Symfony uses so many magic methods and voodoo...
Symfony Version
I'm using Symfony 1.4 for this project. The available web host isn't running PHP 5.3.x yet, which is a requirement of Symfony 2.0
If you want to selectively load assets in different locations in the HTML that Symfony 'prefers', you won't be able to use load_javascripts() and load_stylesheets(). I'm not familiar with HTML5Boilerplate, but if you're still using a layout file, why not just manually put the asset includes where you need them to go? This goes against Symfony's way of using view.yml to queue up assets, but sooner or later with any framework you're going to run into cases where you need to do someting your way.
Again, I'm not familiar with HTML5Boilerplate, so if I'm not seeing something, let me know in the comments.
If you are using Symfony 2.0 you should use OryzoneBoilerplateBundle
What version of symfony are you using?
I use html5boilerplate with symfony (2.0) no problem, simply calling the css and javascript straight from a twig template in my resources folder.
Related
Basically I don't know how to start implementing VueJs into my project.
Should I use a CDN or require it via NPM? NPM would make it easier to implement VueJs packages.
I have in (my own framework (for learning)) a path /public/ in which a index.php file is located, along with an assets folder (which leads is followed css/js folders).
So the question is, what would you recommend, and how would you implement routing etc.?
I personally prefer it to be independent and would download the necessary files and integrate it directly.
Download the development version: https://vuejs.org/js/vue.js and the production version: https://vuejs.org/js/vue.min.js
Copy this files into the public/js folder
Add a script tag: <script src="js/vue.min.js"></script>
I don't get what the really point is on your question, but:
In your case I would use a framework like laravel, symfony, zend, ...
This gives you routing and stuff.
If you want to write the framework yourself (for learning, like you've mentioned) the you should take your brain and implement a concept on how you would like to define the routings.
Concerning VueJs: I think there should be no problem using the CDN-Version. It keeps things simple, until you really need to build VueJS on your development-PC (later within your deployment-process).
As said: Do one step after another. First use the simple way. Implement a simple Routing. Use VueJS from CDN. And when things get serious: Extend the code by your needs. Include VueJS via NPM and stuff like that.
I want to use Laravel Bootstrapper bundle http://bundles.laravel.com/bundle/bootstrapper with my CodeIgniter application.
How can i utilize autoloader functionality to use Bootstrapper bundle code in CodeIgniter in native PHP 5 fashion.
Button::make('Abc')->with_icon('ok');
Do you suggest to convert Bootstrapper bundle in CodeIgniter library or we can use it as it is.
I am using bootstrap for creating views, thus already including bootstrap specific css, js & images.
Please help, so that the bundle can be used with CodeIgniter
Why? It's not designed to work with CI, you'll probably have to mess about alot to get it working. See one of the many versions available for CI here https://github.com/vesparny/codeigniter-html5boilerplate-twitter-bootstrap.
Further more, I dont see any great advantage of having a bootstrap CI integration, if you do then go for it but I just use my own customised bootstrap and load it in as normal in template/view files. Works just fine and keeps all those UI/view bits and pieces separate for designers/Front-end coders who panic at the sight of php.
All this work trying to keep design, function and layout separate and people go to great effort to ruin it with something like this.
I am new to CI. I am using version 2. I noticed like other frameworks CI didn't have folders like assets and layout. Where do i place files like css and js and images. Also where is the layout folder.
You can place your assets directory wherever you desire, putting it under the root CodeIgniter directory is usually the norm.
CodeIgniter has no reason to include an assets directory as that's usually a front-end requirement, of which CI isn't made for (it's a back end MVC framework).
a simple answer is no. CI don't have that. You need to manually create.
And if you are coming from Yii, Ci doesn't implement that feature of Layout.
EDIT
by default, CI doesn't have. You can tweak it but easier implementation is
$this->load->view('header', $param1);
$this->load->view('content', $param2);
$this->load->view('footer', $param3);
where param1, param2, .... are variables you want to pass it to view.
CI will add the views in that order.
and remember, don't put .php while at the end of the filename in view().
No
Is the simple answer, you have to extend CIs functionality and use a library from a third party to provide these features for you. CI doesn't focus on the aesthetics of the "front-end". Its primary focus was "back-end".
Your Options:
look into Phil Sturgeons template library, and CI Sprinkles library first is for layout/theme/partials management, second is for asset management js/css minification and caching.
Phil's Template Library: http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/
Sprinkles Library: https://github.com/edmundask/Sprinkle
Or build your own basic template library
This is a great intro video how to do such. I have used this in the past, before i got into using Sparks.
http://www.youtube.com/watch?v=gvGymDhY49E
you can use Sparks to make lib management a bit easier
In 2.1 sparks aren't included however it is in the dev builds of CI so im sure at a later date it will be merged in with the base code. FOr now you can use this site to install Sparks to help you manage third party libraries.
http://getsparks.org
You don't have to use a template library.
You don't have to programmatically serve the CSS and JS it can just be part of a view file.
But, you can if you want to! CI is incredibly flexible. We've written our own template library that works great for us (we'll release it soon, just checking that it works how we want it to...) but it might not suit the way you work.
Try using this PHP layout manager library, can be integrated with codeigniter easily:
https://github.com/mahadazad/php-layout-manager
its easy to setup and use.
look for assets helper to load css and js file anywhere..
Simple assets helper for codeigniter
I'm trying to implement Symfony2 form builder component as a standalone. The documentation
doesn't really talk about this though, just in relation to using the whole framework.
The standalone is on Github but has no docs.
Ive searched around and seen a few people ask this question but none seems to have any answers.
All I need is a basic guide on how to setup a form , build it, then view it.
Anyone?
Edit: My first response below is now obsolete (and the link does not work anymore). Please refer to
https://github.com/webmozart/standalone-forms for a state-of-the-art solution.
Previous (now obsolete) answer:
I've tried hard and managed to display a form (using PHP engine, not Twig).
Indeed you need a few components: Form, but also ClassLoader, EventDispatcher, Templating (for rendering) and Translation (for rendering labels). You will also need some resources from the FrameworkBundle bundle (mainly templates).
More info on this:
http://forum.symfony-project.org/viewtopic.php?f=23&t=36412
And my mini-tutorial:
http://n.clavaud.free.fr/blog/index.php?article31/symfony2-standalone-form-component-tutorial
First, copy Form Component to your project to directory which contains third-party libraries (not only Symfony components, but also ORM or whatever), let's say lib/, so it's in <project_path>/lib/Symfony/Component/Forms.
Then you have to auoload it - either manually or using any PSR-0 compatible class loader i.e. SplClassLoader or Symfony's UniversalClassLoader (there is chapter in docs and in quick tour about this). Example:
$loader = new UniversalClassLoader();
$loader->registerNamespace('Symfony', __DIR__.'/lib');
$loader->register();
Using Form Component isn't in fact strongly documented, but in Symfony Book there are few examples how to use Form classes about this component, so I guess you'll have to dive into sources, beginning with Form class (maybe later you'll give some feedback about experiences somewhere in the Web?).
Since Symfony 2.1, the form component has been using composer.
You can locate the composer.json file inside the repository. It contains a dependency map that can be used to get the dependencies installed.
You can do so by simply running composer install from inside your console.
P.S I know this thread is old. The information I'm contributing apply to any new users that may need it.
First of all not with Symfony2. But creating form with Aura.Input and some view helpers of Aura.View makes it easy to bring Standalone Forms and Validation.
If you are interested you can read it over http://harikt.com/phpform/ , and source is in github.
/*
* This file is part of the Symfony package.....
what i understand from that line is that the file is a PART of the framework, can't be removed, can't be ripped, and it won't function if you rip it off the package because it requires other related files in the framework
however, there is an option, and it is to investigate the files and see what functions they call and what variables they use ,redefine them, and use it as standalone IF the license allows you to
I'm reading a tutorial for 1.2,which says prototype is the built in library :
http://www.symfony-project.org/book/1_2/11-Ajax-Integration
What about the newest version of symfony?
I'm only familiar with jQuery,is there an easy way to replace the default by jQuery?
I don't believe there is a default in 1.4, no JS library is bundled with the release. To get jQuery method bindings like you had in 1.2 you can use the sfJqueryReloadedPlugin.
As far as i know, it is still prototype. If you can download it, you can easily check this too. Also see what's new in 1.4, there is no mention of new js library being included.
As far as I know, that built-in support is removed in 1.4 and in any case plugins and stuff aren't up to date for that. You're better off just ignoring it and building what you need yourself.
I'm using Symfony 1.4 very happily with Jquery 1.4. You set the Javascript source you need in the view.yml configuration file of the application or module (using the standard Symfony configuration cascade). And I think you can use a Javascript helper to call a .js file on the fly as well.
It all works fine.