RuntimeException Could not scan for classes inside "database/factories" Laravel - laravel

i need to install Laravel charts in my project. after installing
composer require consoletvs/charts:6.*
I have this error :
[RuntimeException]
Could not scan for classes inside "database/factories" which does not appear
to be a file nor a folder
So after when i copy my provides and allias in App folder, i got :
Class 'ConsoleTVs\Charts\ChartsServiceProvider' not found
Anyone can help please ?

I've just had this error crop up. It was because I'd removed all of the files from the database/factories folder. The options to fix were either to add a stub factory file back into the folder. The UserFactory.php that comes with Laravel will do.
<?php
use Faker\Generator as Faker;
$factory->define(App\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
The alternative is to remove from composer.json
"classmap": [
"database/factories"
],

When a composer installation doesn't work right I check that composer itself is updated.
Run composer's self-update command
php composer.phar self-update

Related

"Class 'App\Game\User' not found" even with changed providers

When i try to register an account it comes up with this error " class App\Game\user" not found
I have changed the providers auth.php to App\Game\User::class,
and i have changed the name space on the user.php to namespace App\Game;
Game.php does exist (however nothing is coded in it and im wondering if this is the problem?)
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Game\User::class,
],
the browser highlights the return line in this part of the RegisterController
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
Edit: I didn't realize it meant folders in the naming convention and put them into the appropriate folders. Thank you. My apologies i couldn't find a question relating to this on stackover flow and ive only just started on laravel
First of all if you have something like App\Game\User::Class
That means you will have a game folder inside the app folder and then user.php file in that Game folder with. You can use the full namespace to call the class like \App\Game\User if it's still not working try to run composer dump-autoload to regenerate the composer files.
Laravel model stores under app>user.php and make sure your file does exist in app>game folder

Issue with laravel 5.8 and mongodb 4.2 connection

My system has 2 xampp's one with PHP 5.6 and the other with PHP 7.3. I have correctly included both the PHP versions in environment variables. I am trying to connect my laravel v5.8 application with mongodb v4.2.
I have used jenssegers/mongodb package in my application. Also I have added MongodbServiceProvider in app.php. I am using Robo 3T for mongodb GUI. Now whenever I try to post data to mongodb collection then I get a authentication failed error.N= Below are the codes that I have used in my application.
Database.php(Config folder)
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_DB_HOST', 'localhost'),
'port' => env('MONGO_DB_PORT', 27017),
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => []
],
Todo.php(Model)
namespace App;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class Todo extends Eloquent
{
protected $connection = 'mongodb';
protected $collection = 'todo';
protected $fillable = [
'title', 'desc'
];
}
.env file
MONGO_DB_HOST=127.0.0.1
MONGO_DB_PORT=27017
MONGO_DB_DATABASE=mongocrud
MONGO_DB_USERNAME=
MONGO_DB_PASSWORD=
Overview of Error message:
(1/1) AuthenticationException
Authentication failed.
in Find.php line 299
at Server->executeQuery('mongocrud.todo', object(Query), array('readPreference' => object(ReadPreference)))
in Find.php line 299
at Find->execute(object(Server))
in Collection.php line 624
at Collection->find(array(), array('typeMap' => array('root' => 'array', 'document' => 'array'), 'readPreference' => object(ReadPreference), 'readConcern' => object(ReadConcern)))
First delete vendor folder & replace below 2 line in composer.json:
"jenssegers/mongodb": "^3.5",
"laravel/framework": "5.8.*",
to
"jenssegers/mongodb": "^3.5",
"laravel/framework": "5.7.*",
& update composer
after update the composer clear the config cache.
Make sure you have the MongoDB PHP driver installed. You can find installation instructions at http://php.net/manual/en/mongodb.installation.php

Laravel 5 Payum provider not working

I have installed payum for laravel 5 but my providers are not updating correctly.
I added 'Payum\LaravelPackage\PayumServiceProvider' to app/config/app.php file.
'providers' => [
...
//All my providers
'Payum\LaravelPackage\PayumServiceProvider',
],
also tried as
'providers' => [
...
//All my providers
Payum\LaravelPackage\PayumServiceProvider::class,
],
anyway the error message i get whenever i try to use artisan to make a controller or any other thing is:
am i missing any configuration for the service provider? any help will be apreciated.
EDIT: i have created a new provider and stopped using the default provider.
i ran php artisan make:provider PayumServiceProvider
and into its register method pasted:
...
public function register()
{
$this->app->resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
// this method registers filesystem storages, consider to change them to something more
// sophisticated, like eloquent storage
->addDefaultStorages()
->addGateway('paypal_ec', [
'factory' => 'paypal_express_checkout',
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
'sandbox' => true
]);
});
}
...
Still not working

Laravel 5.5 socialite integration shows error formatRedirectUrl() must be of the type array, null given

I am using "laravel/socialite": "^3.0", to facebook login. But it shows
an error
Type error: Argument 1 passed to Laravel\Socialite\SocialiteManager::formatRedirectUrl() must be of the type array, null given, called in /var/www/html/mas/vendor/laravel/socialite/src/SocialiteManager.php.
It happens when I am calling the below function in my login controller
public function socialLogin($social)
{
return Socialite::driver($social)->redirect();
}
Hi you are missing to give credentials of social media put that in config/services.php
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('CALLBACK_URL_FACEBOOK'),
],
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => env('CALLBACK_URL_GOOGLE'),
],
'twitter' => [
'client_id' => env('TWITTER_CLIENT_ID'),
'client_secret' => env('TWITTER_CLIENT_SECRET'),
'redirect' => env('CALLBACK_URL_TWITTER'),
],
'linkedin' => [
'client_id' => env('LINKEDIN_CLIENT_ID'),
'client_secret' => env('LINKEDIN_CLIENT_SECRET'),
'redirect' => env('CALLBACK_URL_LINKEDIN'),
],
'instagram' => [
'client_id' => env('INSTAGRAM_CLIENT_ID'),
'client_secret' => env('INSTAGRAM_CLIENT_SECRET'),
'redirect' => env('CALLBACK_URL_INSTAGRAM'),
],
You must clear the configuration cache file, how? if you use php artisan you will see the command config:clear. Run it:
php artisan config:clear
and now if you access to the $config variable inside the Laravel\Socialite\SocialiteManager::createFacebookDriver()
you will get the configuration element stored in config/services.facebook (Facebook, for example) that before was not 'visible' for Socialite.
In short: run php artisan config:clear
This happened to me just recently, fixed it after reading the following post here on StackOverflow:
Why do I have to run "composer dump-autoload" command to make migration work in laravel
The solution is basically to run the following commands:
php artisan clear-compiled
composer dump-autoload
php artisan optimize
The problem is with the parameters passed to the function socialLogin($social).
Try by manually setting the 'github' or 'facebook' string in the drvier function of Socialite.
Dont forget to mention 'github' , 'facebook, etc in the route in web.php
I had same problem.
I got this errot because of copy/paste while reading Laravel doc. In my case in loginController.php changed this:
// I copied this from Laravel doc
public function redirectToProvider()
{
return Socialite::driver('github')->redirect();
}
//What I really needed
public function redirectToProvider()
{
return Socialite::driver('google')->redirect();
}
I was having the same issue even after had set up my config/services.php file and managed to solve it by clearing my cache. In your project directory run
php artisan optimize:clear
php artisan cache:clear
php artisan config:clear
php artisan config:cache
This ensures that your entire cache is cleared.
NOTE: changing core files in Laravel most of the times require you running the above commands as Laravel tends to use caching to a greater extend to improve on application speeds
Try these
Check if you have all your social media in config/services.php
On your register or login page check the url that corresponds to facebook
a href="{{ url('/login/facebook') }}"
Go to Routes and check if you have routes properly configured
Route::get('login/{social}', 'Auth\LoginController#redirectToProvider');
Route::get('login/{social}/callback', 'Auth\LoginController#handleProviderCallback');
Open Auth/LoginController and check if have
use Socialite;
public function redirectToProvider($social)
{
Socialite::driver($social)->redirect();
}
public function handleProviderCallback($social)
{
$user = Socialite::driver($social)->user();
}
As you've mentioned you are only facing the error with facebook, im pretty sure it must be in first three steps
Open vendor\laravel\socialite\src\SocialiteManager.php
Replace to
protected function formatRedirectUrl(array $config)
{
$redirect = value($config['redirect']);
return Str::startsWith($redirect, '/')
? $this->app['url']->to($redirect)
: $redirect;
}
Open vendor\laravel\socialite\src\SocialiteManager.php and
Replace
protected function createFacebookDriver()
{
$config = $this->app['config']['services.facebook'];
return $this->buildProvider(
FacebookProvider::class, $config
);
}
To
protected function createFacebookDriver()
{
$config = $this->app['config']['services.stripe.facebook'];
return $this->buildProvider(
FacebookProvider::class, $config
);
}

Laravel 5.2, LaravelCollective 5.2, Class 'Html' not found

I followed these steps but still getting "Html" class not found.
added in composer.json
"require": {
"laravelcollective/html": "5.2.*"
}
once installed, added these lines in config/app.php
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
please see attached screen shot. what can be the reason, I also tried composer dump-autoload composer clear-cache but it didn't resolve the issue
Updated
View sample code
{!!Html::style('assets/css/bootstrap.min.css')!!}
{!!Html::style('assets/css/custom.css')!!}
{!!Html::script('assets/js/jquery.min.js')!!}
{!!Html::script('assets/js/bootstrap.min.js')!!}
I just found the solution here, its worked perfectly.
Followed these steps
composer require laravelcollective/html
it will install html & form as per your installed Laravel version (mine 5.2)
Added Providers and Aliases
Open config/app.php In providers array add
Collective\Html\HtmlServiceProvider::class
and in aliases array add
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class
Found solution here
http://laraveldeveloper.me/form-in-laravel-5-2/
Stackoverflow
https://stackoverflow.com/a/35169836/1216451
https://stackoverflow.com/a/34807375/1216451

Resources