Load css/js files in Laravel 4 with Composer? - laravel

I'm working on creating a new project in Laravel 4. I have a tiny bit of experience in Laravel 3, in which I got used to the assets system. I'm now having a lot of trouble figuring out how to load CSS and JS files in the new system.
I believe I should be using Composer PHP, but I'm not sure how. Where do I put the actual .css and .js files? And then how do I load them with Composer to be utilized in the Laravel project?
I know there are outside plugins like Best Asset, etc. that are written to replicate the Assets system of Laravel 3, but I was hoping to understand the new system and not have to use an outside plugin.
Any help? Thanks.

You don't need Composer for your css/js assets. You can use assets pretty much the same as with Laravel 3
You can just place them in your public folder and reference them in your views. You can use plain html, or use the HtmlBuilder: HTML::style('style.css') and HTML::script('script.js')

You must take care of case sensitive.
This class must write with uppercase.
HTML::style('style.css');
HTML::script('script.js');
Laravel stylesheets and javascript don't load for non-base routes

Related

Laravel 8.x Tailwind Prefix

Tailwind allows prefix to be set in tailwind.config.js.
Reference here.
I'm working on a Laravel project that uses Bootstrap and Tailwind simultaneously, managed by npm. I've set a prefix "tw-" for Tailwind to prevent classes colliding.
However, Laravel 8.x uses Tailwind by default unless set to use Bootstrap. Reference here.
Is there any way to let Laravel know about the Tailwind prefix that I set so that it uses the correct Tailwind class names?
Thanks in advance!
I wonder if it's truly necessary to use both tools for css.
Anyways I'm not entirely sure how you're loading the pagination, but you also have the ability to create your own (custom) pagination view.
By running the following code:
php artisan vendor:publish --tag=laravel-pagination
This command will place the views in your application's resources/views/vendor/pagination directory. The tailwind.blade.php file within this directory corresponds to the default pagination view. You may edit this file to modify the pagination HTML.
It might suite your needs a lot more to be able to have the pagination view file customized. Because with this you can recreate the pagination using Tailwind (or Bootstrap) classes.

Live Edit in PhpStorm for Laravel projects

I like to use Live Edit feature, however, it seems to me it only works with regular .html files, however, none of the known to me ways work with Laravel .blade.php files. Google didn't answer.
Is there really no way to do so?
For Laravel projects, you can use BrowserSync to automatically refresh websites when you make changes to your template files. Support for BrowserSync comes out of the box with Laravel Mix. To use this feature, all you have to do is go to your webpack.mix.js file and add the mix.browserSync() function call. If you're using Laravel Valet or something similar to get pretty URLs, you can pass in a URL as an argument to proxy.
mix.browserSync();
// OR
mix.browserSync('my-domain.test');
Documentation: Compiling Assets (Mix)

External PHP Include in Laravel

We run a main website which is not made in Laravel. A specific script on this website however is made in Laravel. We need this script (or to be exact, a specific view inside of it) to fetch some resources from the main website (PHP files which mainly include HTML). When, inside the Laravel application, we try to include these resources, we can not - as they don't exist in the Laravel project workspace. This results in an error that the file does not exist. Attempting to climb out of the project (../../../file.php) does not seem to help either.
We're including it this way:
<?php
include '~/template/nav.php';
?>
We don't wish to include this file into the actual Laravel project, as that would require having to update it twice to ensure they remain equal. Is there any way for us to include this "external" file in our view? Every bit of research done seems to suggest adding it into the project, which would just cause twice the amount of administration on updates.
Cheers!
Just faced same problem. My Laravel Project is an API that need's to include outside php file. So what I did was specify entire path:
include($_SERVER['DOCUMENT_ROOT'].'/../../my_example_file.php');
$_SERVER['DOCUMENT_ROOT'] will lead you to Laravel's public folder.

code igniter framework guidance for beginners

I am just a beginner in code igniter. I have just downloaded the code igniter framework. But i don't know that where should i keep my html, php files and stylesheets, images etc. Is there any procedure to do the things? Please guide me.
CodeIgniter has an awesome user guide that will come with the install you can read through (or read it online at - http://codeigniter.com/user_guide/ ), or you can watch some of the videos on their site - http://codeigniter.com/tutorials/
In comparison to most other frameworks you're going to find they have maybe the smallest learning curve and great documentation. I would also recommend learning basic PHP and getting familiar with your web environment maybe before beginning.
I used these tutorials to help get me started with the framework haven't look back since! http://net.tutsplus.com/sessions/codeigniter-from-scratch/
hi I am a weekend coder and picked up CI about a year ago.
It helped me a lot.
The best tutorial I found was on the IBM's developer site. It runs through putting together a simple application. Admittedly, there's nothing in it about directory and file placement but it helps cement ideas about how models, views and controllers (MVC), and why MVC is so helpful. Because the basic idea is quite simple, it's worth running through a simple CI tutorial again and again till you 'feel' or intuit the basic helpfulness of the setup.
Things like JS, CSS files can be kept in their own folders at the first level of your website folder e.g /js or /css or /images. You ask about PHP files as well. PHP files which you, the coder, write, are either 'views', 'models' or 'controllers'. These go in the folders with those names in the /application folder e.g /application/views/yourview.php or /application/controllers/yourcontroller.php. The CI install comes with a default view file and a default controller, which you are probably already aware of.
The files inside /application/config are important as well. Read the user-guide about tweaking these files. The most obvious tweaks are to database.php to connect to your db, autoload to give automatic use of CI helpers/libraries which you can choose, and to config.php to give CI the name of your website e.g the name you give to '/'.
The file 'index.php' comes with the CI installation (/index.php). You don't need to fiddle with it at all really except to determine the level of error reporting you want ('environment') and that's not a priority at all. But it's important to remember this about index.php - that CI uses it as the essential reference for defining paths to useful folders like CSS or images. So even if your view file is in /application/views, if it refers to an image like a logo.gif in /images for example, the path to it is just /images/logo.gif. It is not anything more complicated like ../../images/logo.gif.
I hope that helps.
Tom
Offline version of CodeIgniter user guide is available with CodeIgniter which already downloaded by you.
just extract your CodeIgniter zip file in your localhost server root directory,
Then http://localhost/www/CodeIgniter_2.1.2/user_guide/ open this url with browser ,here you can access offline version of CodeIgniter user guide.
Here I am using wamp server so I used this url, If you are using xampp server then please use http://localhost/CodeIgniter_2.1.2/user_guide/
Okay this is what I would usually do for code igniter
here is my directory structure.
CI App Path (e.g "c:\xampp\htdocs\ci_app_name" )
-application
-system
-assets
--css (new folder , where css files will be included)
--js (javascript and jquery libraries location)
Basic HTML and PHP files should be location
CI_app_pah
-application
--views (this is where to put HTML and PHP files)
For other things such as Controller , Models and Views , you can't put any where but put in their related area.
That will be
CI app
-application
--controllers
--models
--views

In an external assets folder the best place to put libraries for CodeIgniter 2.x?

when I last used CodeIgniter it was version 1.x and I read an external assets folder for css, js, and images was the best way to handle things. I wanted to know if that is the correct way to do things in 2.x. I found this on SO but it didn't address it directly:
Assets in codeigniter
The other SO entries were too old to address 2.x.
Thank you.
As long as they are both publicly accessible then there is no difference between
application
...
system
...
assets
css
style.css
images
image.png
and
application
...
system
...
css
style.css
images
image.png
Depending on your .htaccess file you may need to make a change but CodeIgniter doesn't require you to use any specific scheme for storing assets.

Resources