How to install laravelcollective html in laravel 5 without using composer - laravel

I'm using laravel 5.5 and I want to install laravelcollective without using composer. I have followed steps mentioned in other questions to install it in laravel 5.2 but it is generating the following error.
Class Collective\Html\HtmlServiceProvider not found
Please suggest the possible reasons for the error.

Shashank Simha M R, I think the best way to go is by installing it via composer like this: composer require laravelcollective/html "5.5.*".
Here, you just specify the version of the Laravel you've installed. Otherwise, composer will not be able to install it.
After that, you just update the config/app.php file like so:
Add the following line to the $provider array:
Collective\Html\HtmlServiceProvider::class
Then find the aliases array and add these two aliases to the aliases array:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
That is it!

Go to this link:
https://github.com/LaravelCollective/html
download the package and extract it to /vendor/ folder so that you have this path
/vendor/laravelcollective/html/src/HtmlServiceProvider.php
Next, add your new provider to the providers array of config/app.php:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
And it should work.

Related

In ProviderRepository.php line 208: Class 'Sentry\SentryLaravel\SentryLaravelServiceProvider' not found

I'm trying to install Sentry Error Tracking into my Laravel 5 Project. It throws an Error when i try publishing the Provider using the command
php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"
I added this into config/app.php
'providers' => array(
// ...
Sentry\SentryLaravel\SentryLaravelServiceProvider::class,
)
'aliases' => array(
// ...
'Sentry' => Sentry\SentryLaravel\SentryFacade::class,
)
Then i ran
php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"
And it threw the Error
In ProviderRepository.php line 208:
Class 'Sentry\SentryLaravel\SentryLaravelServiceProvider' not found
I've been searching for various solutions but none of them worked for me. This is very important for my project. Can i please please get some assistance. Thank You.
I recommend official sentry documentation.
https://sentry.io/for/laravel/
Not sure what is your exact development environment.(OS, PHP version, laravel version etc).
Here are something you can check.
check your installed sentry laravel package. If you did not install it, use next command to install.
composer require sentry/sentry-laravel
check version of sentry/sentry-laravel from composer.json.
Please notice after version 1.x namespace has been changed to
'providers' => array(
Sentry\Laravel\ServiceProvider::class,
)
'aliases' => array(
'Sentry' => Sentry\Laravel\Facade::class,
)
Namespace update
version 0.x
Sentry\SentryLaravel\SentryLaravelServiceProvider::class
https://github.com/getsentry/sentry-laravel/blob/0.10.1/src/Sentry/SentryLaravel/SentryLaravelServiceProvider.php
version 1.x
Sentry\Laravel\ServiceProvider::class
https://github.com/getsentry/sentry-laravel/blob/1.0.0/src/Sentry/Laravel/ServiceProvider.php

How to fix "Non-static method Spatie\Analytics\Analytics::fetchVisitorsAndPageViews() should not be called statically?"

When i put:
use Spatie\Analytics\Analytics;
It gives the error
'Non-static method should not be called statically'
But when I only put:
use Analytics;
I gives a white page on refresh or says
"The use statement with non-compound name 'Analytics' has no effect "
when starting.
I am using Laravel 5.5.4 and although it says the facade should be automatically setup, it wasn't working so I also added this manually to the // config/app.php:
'Analytics' => Spatie\Analytics\AnalyticsFacade::class,
But it still is not working.
from the package github. there was a solution
php artisan config:clear
but it did not work for me.
This package can be installed through Composer.
composer require spatie/laravel-analytics
In Laravel 5.5 and above the package will autoregister the service provider. In Laravel 5.4 you must install this service provider.
config/app.php
'providers' => [
...
Spatie\Analytics\AnalyticsServiceProvider::class,
...
];
In Laravel 5.5 and above the package will autoregister the facade. In Laravel 5.4 you must install the facade manually.
config/app.php
'aliases' => [
...
'Analytics' => Spatie\Analytics\AnalyticsFacade::class,
...
];
You want to use the facade to access the class, you will need to change:
use Spatie\Analytics\Analytics; to use Analytics;
Another way around just import this to your class:
use Spatie\Analytics\AnalyticsFacade as Analytics
It depends in what context you place the use statement.
In Laravel you also can use facades without having to import it with use.
The same class can be called by using \Analytics in your code call.
Example:
\Analytics::fetchMostVisitedPages(\Period::days(7));

How can I install Collective\Html\HtmlServiceProvider without composer?

I am on a cpanel shared hosting and don't have access to SSH. How can I install Collective\Html\HtmlServiceProvider without SSH?
If I had SSH access I would use:
composer require laravelcollective/html
But I don't know what to do now.
Another solution would be downloading it locally with composer and uploading the entire project (including the vendor folder) with a ftp client.
Step 1:
Go to https://github.com/LaravelCollective/html and download the repo.
Step 2
Copy the zip and navigate to your project. Inside the vendor folder create folder laravelcollective and then inside html. Inside the html folder place the repo.
Step 3
On your composer.json file on the root directory of your project add the following lines.
"autoload": {
"psr-4": {
"Collective\\Html\\": "vendor/laravelcollective/html/src/"
},
}
and then do
composer dump-autoload
Step 4
Next, add your new provider to the providers array of config/app.php:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],

Laravel Class 'Socialite' not found

Using composer, I have installed Socialite package to my local machine. It works well. Then I upload all the vendor/laravel/socialite directory as it is to server. Then on server, in composer.json added the line -
"laravel/socialite": "^2.0"
Also, in config/app.php make below changes -
In provider section add the line -
Laravel\Socialite\SocialiteServiceProvider::class,
In aliases section add this line -
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
Then, as per documentation add below code in config/services.php file -
'facebook' => [
'client_id' => '{{my_client_id}}',
'client_secret' => '{{my_secret_key}}',
'redirect' => 'http://mydomain/public/callback',
],
The Controller, I am using has included use Socialite; at top.
Bur now, it gives me error as Class 'Socialite' not found on server. Where as it works fine on my local machine.
Am I missing something to upload on server?
Your help is appreciated.
Thanks.
You need to do dump autoload everytime you make changes in composer.json, composer dump-auto

composer package only for development in laravel providers

If I have a package (that I have to add to app/config/app.php providers/aliases) that I only really want on my development boxes (b/c I only use for development) is there an approach that will allow me to do this leveraging composer require --dev <package> along w/ composer install --no-dev
I need to add an index into both the providers and aliases array...but I would prefer NOT to manage those large arrays in multiple config environment folders if possible
Create a folder in your config directory that matches your environment name. dev in this case.
Next, recreate any files you wish to override and place them into that folder. app.php in this case
Next open bootstrap/start.php and find $app->detectEnvironment. The array passed to this method determines which environment you are working with. Setting the key to this array as dev will overwrite any of your config files with their counterparts in your dev folder.
If you do not wish to create an entirely new providers array in app.php file for each environment and say you only wanted to add a certain provider to your dev environment, you may use a helper method like so...
'providers' => append_config(array(
'DevOnlyServiceProvider',
))
All this information was pulled from the Laravel documentation found here: http://laravel.com/docs/configuration
For anyone looking how to do this in Laravel 5, you can still emulate the L4 behaviour.
On the top of app/Providers/AppServiceProvider add:
use Illuminate\Foundation\AliasLoader;
And then edit the register() method:
public function register()
{
$path = $this->app->environment() .'.app';
$config = $this->app->make('config');
$aliasLoader = AliasLoader::getInstance();
if ($config->has($path)) {
array_map([$this->app, 'register'], $config->get($path .'.providers'));
foreach ($config->get($path .'.aliases') as $key => $class) {
$aliasLoader->alias($key, $class);
}
}
}
Then just add config/<YOUR ENVIRONMENT NAME>/app.php config file and define additional providers and aliases, same as in app.php
For example:
return [
'providers' => [
Barryvdh\Debugbar\ServiceProvider::class,
],
'aliases' => [
'Debugbar' => Barryvdh\Debugbar\Facade::class,
],
];

Resources