I have developed a component to crop images, and now I am migrating it to Yii 2.
There are a PHP class, a JS, a CSS, and an image files.
I am in doubt whether I place these files. Is it better to create a directory at basepath/vendor, or to add in the respective directories (image, css, and js), on backend/web and reference them in backend/assets/AppAsset? Note that I will only use this component in the backoffice.
What is the conventional way to do this?
For my experience is better build a component in vendor/yourVendorName/yourModuleName in the form of module and the you can use it where do you prefer adding to modules section of config/main.php of your app
Related
I am new learner on Laravel.
I am using Laravel 5.3.But I want Use Bootstrap css and Js.
But Laravel have default app.css and app.js.
Hare app.css actually Bootstrap CSS and also app.js work like Bootstarp js.
But can i delete app.js and app.css and can i use custom version Bootstrap CSS & JS ?
So I need to know why we will be use this two files ?
You can delete them, read the following lines:
CSS
Laravel Elixir provides a clean, expressive API over compiling SASS or Less, which are extensions of plain CSS that add variables, mixins, and other powerful features that make working with CSS much more enjoyable.
In this document, we will briefly discuss CSS compilation in general; however, you should consult the full Laravel Elixir documentation for more information on compiling SASS or Less.
JavaScript
Laravel does not require you to use a specific JavaScript framework or library to build your applications. In fact, you don't have to use JavaScript at all. However, Laravel does include some basic scaffolding to make it easier to get started writing modern JavaScript using the Vue library. Vue provides an expressive API for building robust JavaScript applications using components.
Complete Reference
Laravel default CSS and JS files are safe to remove.
However, these styles will be used in the following places by default, so please be taken care of it.
Default Welcome page
Laravel auth pages
Default error page
If you are using custom themes or your own styles, you can use Laravel Elixer to compile them and which will create app.css for style files and app.js for javascript related files.
https://laravel.com/docs/5.3/elixir
https://laravel.com/docs/5.3/frontend
I understand this sort of breaks the structured point of Laravel, but there is method to my madness. I plan on using a single install of laravel to host several websites that are database driven. At the moment all of the sites share the same layout and I have a system to store some custom CSS in the DB to give each site a different color scheme. I want to change this so they can use completely different views. So site A loads views/theme1/app.blade.php and site B loads views/theme2/app.blade.php.
I have implemented this by using the following to return a view.
$theme = getDomainThemeName();
return view($theme.'/home');
This is also working, but i am now left with the task of dynamically loading the assets. I am using bootstrap the generate the themes and making a few tweaks to the HTML to create the app.blade.php file. I have 2 potential solutions to this but i would much rather a way to server the css files from the views directory. This means the following mapping.
http://website.com/css/style.css =>
/resources/views/theme1/css/style.css
Can something like this be done? Another option would be to use php to read the css file and insert it into the app using a yield. It works, but it means i cant use browser caching to cache the assets. I was also thinking i could just create sub directories in the public folder. public/theme1/css/style.css. This makes the most logical sense, but it means i have to fragment the theme system. Id like to be able to unzip a theme in the views directory and it just works.
I am using Laravel 5, i have root access to the server too. Running PHP 5.4 on centos 7.
I think the best approach is having next structure:
/public/css/style.css
/public/css/theme1/custom1.css
/resources/views/common.blade.php
/resources/views/theme1/main.blade.php
And then loading conditionally with php each site theme.
It may not be any trouble with caching.
This is more a technical question than a real problem so I don't know if it will be removed but I will ask it anyway.
So I am developing some platform using Symfony2, AngularJS, RequireJS and other tons of stuff I need, everything works with harmony and peace, but I want to create some panels in pure HTML (no twig files) so AngularJS can load it using ngRoute, but thoose files need to reside in /web/partials (for example) to be loaded correctly, because assetic wont generate thoose files inside /bundles/foo/barbundle/partials/*.html as they are not JS, CSS or Images...
The question is simple, is there any way to either force AngularJS to load TWIG templates as partials or forcing Symfony2 assetic to dump my partials inside web folder?
I know that putting manually inside /web is enough to load everything I need and it is loading perfectly in production, but I want to keep some folder structure and keep all my frontend stuff in the same folder /src/Foo/BarBundle/Resources/public/*
UPDATE
I just saw that assets are installing my html files inside my bundle public folder, I don't know why it didn't work before but creating them inside src/Foo/BarBundle/Resources/public/partials and then app/console assets:install --symlinks links them to /web/bundles/foobar/partials, as I say, it didn't work before...
But the question about loading twig files with AngularJS still there.
So, you can easily load your partials from the web folder using app/console assets:install --symlink to place partials and set the good asset path in your angular routing (like /web/bundles/foobar/partials/*.html).
Load twig templates using Angular ngRouter is not a good thing, because PHP is an interpreted language. But load your partials in a Twig template using ngView is possible (PHP is interpreted, and after you switch markup with angular routes).
I'm already running a desktop website with views and template files. Now I would like to develop a mobile version of my website.
I've already detect smart devices by using WURFL library within my own Plugin and I inject that plugin during application initialization.
I'm using Zend ContextSwitch Helper to change the context of current view file with suffix 'mobile' like: index.mobile.phtml.
What I need to organize my existing views under separate folder for mobile like: /views/mobile/index.phtml not as /views/index.mobile.phtml (same folder).
//Add Context
$this->addContext('html', array('suffix' => 'mobile'));
Please advise me how can I tell application to search mobile views under mobile for every views.
I'm using Zend Framework 1.12 version
Your desired approach may be confusing because /views/mobile/index.phtml will refer to "mobile" controller
You may override this by simply changing the template path destination for mobile templates. $view->setScriptPath('mobile')
Another way is to store them in the same folder but with different suffix /views/controller-name/action-name.mobile.phtml
You can achieve this just by changing the view extension using view renderer. $viewRenderer->setViewSuffix('mobile.phtml');
Or you may rewrite your templates using responsive webdesign :-)
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