Doesn't Codeigniter have folders like assets and layout - php

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

Related

Using Laravel with an existing website

I have an existing website running on PHP, MySQL CSS, JS and Ajax.
For future projects, I would like to use the Laravel framework to create new pages or functionality to the existing website... let's say a blog, for instance.
Is this possible?
Is the Laravel framework compatible with an existing website that is not set up using the MVC framework?
The reason is that I would like to make my work easier and more efficient and the use of a framework would be helpful.
Please let me know if you need any other info, I know the question is a little broad.
Thanks,
Justin
yes it's possible but of course maybe with difficulties.
you should put your web files in /views directory, convert your php files to controllers or library files and put your assets in /public directory.
then you can assign routes to your controller and call it form outside of the application.
main job is put your code into controller or libraries. is it possible to split your code into separate logical units? and extract model logic (as php mvc says) from your main code.
so if you have a clean code with good design and minimum dependencies you can think more about it. this could be a good challenge if you go through it cautiously. be careful to not fail and waste your time.

Conventions project with PHP and VueJs?

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.

Load Vendor javascript files CakePHP 2

does everybody know how to load javascript files (as opposed to php classes) from a third party library (placed in app/Vendor/LibraryName). I tried to look into App::import(), but apparently it's only to import classes. I'm trying to use Jssor slider library in a CakePHP 2.5.5 application.
Thanks in advance for any help
if it's a .js file is best to put the files on /app/webroot/js/jssor_library.js this route. then you can use the library on the controller or the view by loading so:
echo $this->html->script('jssor_library');
once loaded, the code is the same as when you use it regularly.
good if an entire folder, then copy the folder path and calls the library you're using, including the name./app/webroot/js/folder_jssor/jssor_library.js
echo $this->html->script('folder_jssor/jssor_library');

Using Laravel bundle with CodeIgniter

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.

Symfony + HTML5Boilerplate integration?

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.

Categories