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

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,
// ...
],

Related

How to install laravelcollective html in laravel 5 without using composer

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.

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

Laravel 5.1 PHPexcel install error

I want to add class PHPExcel to my project. I use composer to add PHPExcel. I tried some command line.
php composer.phar update
or
php composer.phar require phpexcel/phpexcel
But, i alway receive error look like image:
at here. And maatwebsite/excel, too.
What is wrong with my project? Please help me!
First open the file composer.json
and find require object/array and add line
"require": {
"maatwebsite/excel": "~2.1.0"
},
and composer update so composer update is completed
and open the file config/app.php
and find providers object/array and add line
'providers' => [
/*
* Application Service Providers...
*/
'Maatwebsite\Excel\ExcelServiceProvider'
],
and find aliases object/array and add line
'aliases' => [
'Excel' => Maatwebsite\Excel\Facades\Excel::class
]
Remove this line:
"jrenton/laravel-scaffold": "dev-master"
and run composer update again.
jrenton/laravel-scaffold needs "fzaninotto/faker": "1.3.0", which I guess, was used in lower versions of Laravel

Adding a paths to Laravel 4.1 paths.php

Laravel 4.1 has a file paths.php and it has some paths: app, public, base and storage.
I wish to add another path so what I did:
I wrote this in paths.php
'upload' => __DIR__.'/../some/path/uploads',
Then I copied and pasted and edited this in helpers.php
if ( ! function_exists('upload_path'))
{
function upload_path($path = '')
{
return app()->make('path.upload').($path ? '/'.$path : $;
}
}
But after a few days it disappeared!
I am wondering if I did it wrong.
Never edit files in the vendor directory, it and its contents is entirely managed by Composer, and its contents will be overwritten when doing composer update.
If you want to add your own custom functions, autoload them in your composer.json using the "files" autoload rule.
"autoload": {
"files": ["app/helpers.php"]
}
The "Best" way I found to handle this were the included configuration folders.
Inside root/app/config/ you can add a host specific folder (there is one called local by default).
You can add someFolderName and then inside root/bootstrap/start.php update this array:
$env = $app->detectEnvironment(array(
'local' => array('outLocalHostsName'),
'someFolderName' => array('SomeOtherMachinesHostname'),
));
Now go back to the folder and create an app.php file inside it (remember root/app/config/someFolderName/app.php) and add some value in it like so:
'someKeyNameHere' => 'some path string here'
Now you can access it anywhere using:
Config::get('app.someKeyNameHere')
This seems to work great for me.

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