How can I require composer autoloader in the laravel? - laravel

I want to install guzzle https://github.com/guzzle/guzzle
I read the reference, but I'm confused this section :
From that tutorial, asking for require composer autoloader. So seems needed to add require 'vendor/autoload.php';
Where I add the script?
I using laravel 5.6

You don't have to do anything if you are going to install guzzle in Laravel.
The example above is for core php actually. Laravel will automatically do it for you.
Just run composer require guzzlehttp/guzzle in your terminal. (of course in the directory where your laravel project actually is.)
And add use GuzzleHttp\Client; at the top of the file you will be calling guzzle from.

Related

Does tailwind need upper version of php?

I want to install a tailwind package for my laravel project.
I write in Terminal: composer require composer require laravel-frontend-presets/tailwindcss --dev
The error is:
Your requirements could not be resolved to an installable set of packages.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I expect to install all packages correctly.
This package looks like the same of Laravel Breeze one of the official starter kit.
I recommend to use Laravel Breeze or Laravel JetStream that are both served with tailwindcss, and you can use both as well with InertiaJS for Server Side Rendering and choosing between VueJS or ReactJS as javascript framework.
Check Out this:
https://laravel.com/docs/9.x/starter-kits

Laravel Aws\Kinesis\KinesisClient not found

I would like to use Aws\Kinesis\KinesisClient on my Laravel project but unfortunately, when I install package using
composer require aws/aws-sdk-php
and try to use
use Aws\Kinesis\KinesisClient;
I got
Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Aws\Kinesis\KinesisClient not found.
Please guide me how to use KinesisClient on laravel project.
Regards.
The documentation says that; you need to include vendor/autoload.php before using it.
<?php
// Require the Composer autoloader.
require 'vendor/autoload.php';
use Aws\S3\S3Client;
If you don't want to require on every class you use, then maybe you may check this repository to load with service provider. (more laravel way)
This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your Laravel and Lumen applications.

Using the Google Analytics PHP Client Library in Laravel

I am fairly new to Laravel and am trying to integrate the Google Analytics PHP Client Library (https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php) in an application I am building.
According to the documentation , the library needs to be installed via Composer and then loaded using:
require_once __DIR__ . '/vendor/autoload.php';
In the vendors folder, I can see that there is a folder named google. So my question is, what would be the correct way to load this library in Laravel? Would it be using the code shown above, or some other method?
Thanks
The autoload.php file is already required by your laravel app, you should be able to access it by it's namespace after running composer dump-autoload as suggested by Ayaz.
You may want to look at a package like https://github.com/spatie/laravel-analytics where they've done the work to integrate the google analytics api into Laravel a bit more. Even if you don't use it I'm sure you can glean some good info from checking out the source files.
According to the documentation , the library needs to be installed via Composer and then loaded
You can do it by executing following command in your git bash or cmd
$ composer dump-autoload

Does laravel has any gems to extend or modify functionality?

Does laravel has gems like as ruby on rails have? Like, for signup flow ruby on rails has "devise" gem. Does laravel has anything like that?
There is no built-in package manager for Laravel but you can use reference like: https://packalyst.com . Here you can find all available packages for Laravel. All of them can be installed with Composer - php package manager. There is detail description how to install every pack in Packalyst.
If you want to have auth in Laravel you have two options. To do it manually, or to use the built-in module for authentication. You can run
php artisan make:auth
in the main project directory. This will add the required views and routes in the Laravel file structure in order to use the auth. Better to run this command on fresh installation. See this for detailed step by step authentication with Laravel 5: https://laravel.com/docs/5.5/authentication#authentication-quickstart

Laravel and HTML Form Builder

I like the Form Builder. Go Laravel.
What's the difference between the Illuminate version and the Laravel Collective version, and which should we use? Is the Illuminate version now defunct?
You have an explanation here : http://laravel.com/docs/5.0/upgrade#upgrade-5.0
under Form & HTML Helpers
Basically, the Illuminate versions of the Form helper and HTML helper are deprecated in the current version of Laravel and have been removed from the framework's core. They are now maintained by the Laravel Collective.
So if you working with Laravel 5, you should use the Laravel Collective version, you can find it here: laravel Collective: Forms & HTML
In Laravel 5 it is not standard anymore, but you can add it quickly in the composer file if you prefer to work with forms like you did in Laravel 4.
Just add this line in the composer.json, under the require section:
"illuminate/html": "5.*"
After this step you first need to run the composer update command and you should be good to add the rest.
Then you need to add the service providers in config/app.php under providers section like this:
Illuminate\Html\HtmlServiceProvider
And as the last part enter these two lines in the config/app.php under aliases section:
'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade'

Resources