I followed the instructions here
https://laraveltips.wordpress.com/2015/06/15/how-to-make-user-login-and-registration-laravel-5-1/
for setting up login and registration.
Login and registration works correctly, but when I click on Forgot Password, I get the following exception :
ErrorException in ResetsPasswords.php line 104: Argument 1 passed to
App\Http\Controllers\Auth\PasswordController::showResetForm() must be
an instance of Illuminate\Http\Request, null given, called in
ResetsPasswords.php on line 92 and defined
Not sure what is causing this since the request object seems to be getting passed in correctly
public function getReset($token = null)
{
return $this->showResetForm($token);
}
I am running laravel 5.2.6
If it says it needs 'an instance of Illuminate\Http\Request' then pass it one.
public function getReset(Request $request, $token = null)
{
return $this->showResetForm($request, $token);
}
In the laravel 5.2.6 tag there seems to be a bug in the ResetsPassword trait I had the some problem lookup the ResetsPassword.php on github and use the tag v5.2.6 and you will see that the Request is not passed to the showResetForm method you can fix this by manually adding it to the ResetsPassword trait but it would be better to just checkout laravel 5.2 in your composer file.
So in your composer.json it now probably looks like this for you.
"laravel/framework": "5.2.*"
But when you change it to
"laravel/framework": "5.2"
and run composer update
It should be fine atleast it worked for me. An alternative is to use the solution lagbox provided but then you have to change it manually on your server.
Related
I'm trying to implement a new method in a BoController called "deleteBooking", the method is defined:
public function deleteBooking($id){
$booking = Reservation::find($id);
if($booking && $booking->delete()){
try {
$email = Mail::to($booking->user_email)->send(new Cancel($booking));
} catch(\Exception $e){
Log::error($e->getMessage());
}
return redirect('admin/manager/home')->with('message','Réservation annulée!');
}
return redirect('admin/manager/home')->with('message','Réservation non annulée!');
}
But laravel at the endpoint says:
(1/1) BadMethodCallException
Method [deleteBooking] does not exist.
Other methods from the same class are linked to endpoints too, and work well.
Do you have any ideas please? Thank you.
I got it fixed, I've found another file called BoController, in another folder somehow and it was conflicting with the App\Http\Controllers one.
Thank you.
It's most likely that you have declared that function for some other request type other than the one you're trying to make. For example you put Route::post('some-method', 'BoController#deleteBooking'); but you need to put either Route::get(...) or Route::put(...) or Route::delete(...).
If it isn't that problem, then you probably misspelled it.
I have faced similar issue. Then I have figured out a issue pointed in composer install log, with following instance of log line:
Class App\Http\Controllers\BlogController located in ./app/Http/Controllers/BlogControllerOld.php does not comply with psr-4 autoloading standard. Skipping.
Based on that I have found that one of the file renamed with Old suffix was creating conflict with the main file. So here I have to chhoseone of the following solutions:
To delete the file created for backup.
Or just rename the class in duplicated file to BlogControllerOld.
So its a good idea to check for issues with composer install
It will highlight the conflicts that can be fixed using one of the method above.
Once fixed using specified methods above issue composer install to apply the fix and regenerate autoloader.
I'm using irazasyed/telegram-bot-sdk to make a telegram bot.
but when I installed the dev-develop first I got this error :
Cannot use Telegram\Bot\Objects\Message as Message because the name is already in use {"exception":"[object]
(Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 64): Cannot use Telegram\\Bot\\Objects\\Message as Message because the name is already in use at D:\\wamp\\www\\botshop\\vendor\\irazasyed\\telegram-bot-sdk\\src\\Methods\\Payments.php:5)
But after that when I commented use Telegram\Bot\Objects\Message; in line 5 of Payments.php , error not shown again.
But another problem was created that said :
Declaration of App\Commands\StartCommand::handle($arguments) must be compatible with Telegram\Bot\Commands\Command::handle()
this is a simple StartCommand that is also used by itself package in all example of creating new command :
class StartCommand extends Command
{
protected $name = "start";
protected $description = "Start Command to get you started";
public function handle($arguments)
{
$this->replyWithMessage(['text' => 'Hello! Welcome to our bot, Here are our available commands:']);
}
}
I'm using php7.0.10 and laravel 5.5.
The handle function doesn't take any argument by default on the Telegram\Bot\Commands\Command class.
Since you don't use the $arguments variable, you can delete it from the handle function parameters and your code should work again.
I'm using a middleware for handle https over Cloudflare, this is the code:
if(env('I_AM_BEHIND_CLOUDFLARE'))
$request->setTrustedProxies( [ $request->getClientIp() ] );
if (!$request->secure())
return redirect()->secure($request->getRequestUri());
return $next($request);
this code was working before my last composer update that updated symfony component of laravel. it shows an exception about InvalidArgumentException.
symfony in last update changed setTrustedProxies() function that requires second parameter as known headers.
Question: How should I set this second parameter?
You should pass as second argument either of Request::HEADER_X_FORWARDED_ALL or Request::HEADER_X_FORWARDED_FOR
Reference: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L575
I have upgraded Laravel from 4.0 to 4.1 recently in a few instances. Today I did the upgrade in yet another instance and found out that there is something wrong with the User model. The models/User.php file is still there, but I don't think it is used by Laravel anymore. My question is: why?
To demonstrate the issue, I have created the following entries in my routes.php:
Route::get('test1', function()
{
$course = Course::find(4);
return ($course->users()->first());
});
Route::get('test2', function()
{
$user = User::find(22);
return ($user->courses()->first());
});
Both these entries are correct regarding syntax and the database object (course with id 4 exists and user with id 22 exists). My Course.php model has the following:
public function users()
{
return $this->belongsToMany('User')->withPivot('participant_role')->withTimestamps();
}
And my User.php has a corresponding entry:
public function courses()
{
return $this->belongsToMany('Course')->withPivot('participant_role')->withTimestamps();
}
Now if I launch the first URL, /test1, I get a working JSON entry as a result. As expected.
With the second URL, /test2 however I get an error message:
BadMethodCallException
Call to undefined method Illuminate\Database\Query\Builder::courses()
open: /home/simoa/laravelapps/clientname/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php `
I think there is something wrong here. Why is my Laravel instance trying to call the courses() method from the Illuminate\Database\Query\Builder class? That isn't normal, right?
As I said earlier, everything else works perfectly, except things to do with the User model.
The issue was caused by an invalid entry in the file vendor/composer/autoload_classmap.php.
For some reason during the 4.1 upgrade (probably running the command: composer update) the entry for 'User' => $baseDir . '/app/models/User.php' has turned into 'User' => $baseDir . '/app/models/old_User.php' in that file.
I did have an old backup/dev file called old_User.phpin my models directory and for some reason, it seems, composer has mapped User class to that file.
Solution: delete old_User.php and re-run composer update.
try running php artisan clear-compiled and then php artisan optimize
This is a continuation of my last question.
Hi,
I'm implementing, in a Symfony2 application, a custom authentication provider in order to authenticate against the Wordnik REST API.
On application load, no matter what request path, this is the exception I get:
( ! ) Fatal error: Cannot access parent:: when current class scope has no parent in /[..]/WordRot/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php on line 43
You can see the full stacktrace here.
Second to last line in the trace reveals that it is loading the DaoAuthenticationProvider:
18 0.0217 1922792 Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider->__construct( ) ../appDevDebugProjectContainer.php:3071
But none of my configuration refers to that provider, or anything that extends it. My custom provider directly implements the AuthenticationProviderInterface.
So I assume that my configuration is wrong, and somewhere I need to be explicitly setting the WordnikProvider, but I'm not sure where! Research has not provided any clues to this issue.
Any help would be much appreciated!
Files
/app/config/config.yml
/app/config/security.yml
/src/WordRot/PlayBundle/Security/Authentication/Provider/WordnikProvider.php
/src/WordRot/PlayBundle/Security/Authentication/Token/WordnikUserToken.php
/src/WordRot/PlayBundle/Security/Firewall/WordnikListener.php
/src/WordRot/PlayBundle/DependencyInjection/Security/Factory/WordnikFactory.php
the line return $this->authenticationManager->authenticate(new WordnikUserToken($username, $password, $this->providerKey)); in the WordnikListener goes to
Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager (classes.php)
authenticate.
$this->providers are DaoAuthentificationProvider, WordnikProvider and AnonymousAuthentificationProvider.
From the DaoAuthentificationProvider it only uses the method supports($token):
return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey();
which returns false so next in line is WordnikProvider.
Oh..misread: the error is in the constructor:
parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); seems to fail. Running PHP 5.4.10 or so I DON'T have an error!!
Either rm -rf vendor and run composer install again or try using a different PHP version!!
A had to create something like this a week ago.
At the and, I created a custom user provider, where I simply call the api and with the response i create the user or not.
I would advise to read this:
http://symfony.com/doc/2.0/cookbook/security/custom_provider.html