I am working on an integration between my laravel 5.2 app and MailChimp. I have downloaded and installed the spatie/newsletter https://github.com/spatie/laravel-newsletter but form some reasons the integration doesn't work meaning a contact is not created in mailchimp. I have added the providers and aliases in the config/app.php file, config/larave-newsletter.php file contain the proper settings
/*
* The api key of a MailChimp account. You can find yours here:
* https://us10.admin.mailchimp.com/account/api-key-popup/
*/
'apiKey' => env('MAILCHIMP_APIKEY'),
/*
* When not specifying a listname in the various methods, use the list with this name
*/
'defaultListName' => 'ListName',
/*
* Here you can define properties of the lists you want to
* send campaigns.
*/
'lists' => [
/*
* This key is used to identify this list. It can be used
* in the various methods provided by this package.
*
* You can set it to any string you want and you can add
* as many lists as you want.
*/
'subscribers' => [
/*
* A mail chimp list id. Check the mailchimp docs if you don't know
* how to get this value:
* http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id
*/
'id' => env('MAILCHIMP_LIST_ID'),
],
],
/*
* If you're having trouble with https connections, set this to false.
*/
'ssl' => true,
My controller contains the following:
Newsletter::subscribe($user->email, ['FNAME'=>$user->first_name, 'LNAME'=>$user->last_name]);
The strange thing is when I use tinker to add a contact, it does work
Newsletter::subscribe($user->email, ["FNAME"=>$user->first_name, "LNAME"=>$u
ser->last_name]);
Is there a workaround for this issue and how can I solve it? Thanks
I was able to fix the issue by changing the default ssl setting from true to false. It appears my server was having some issues with https connections.
Should one experience a similar issue, they can try setting 'ssl'=>false in the config/laravel-newsletter.php file maybe it'll fix their issue.
I solved the same problem
run this commandes :
composer install
php artisan config:cache
php artisan route:cache
I was able to get this working by setting 'endpoint' to null instead of an empty string (as specified in the install instructions) in config/newsletter.php
Related
I am getting the error below when trying to access the route, but the controller is needed to load the data:
(1/1) InvalidArgumentException
Action Facade\Ignition\Http\Controllers\ShareReportController not defined.
I am using Tenancy/Multi-Tenant package and I have configured it to use routes/tenants.php to load routes specifically for tenants. If I do the following in the tenants.php file, it returns the proper response.
Route::get('/test', function() {
return 'Test success';
});
though when I try to do the same, but loading the data from a controller such as this:
Route::get('/testt', 'TenantController#testt');
It will show the error:
(1/1) InvalidArgumentException
Action Facade\Ignition\Http\Controllers\ShareReportController not defined.
If i try to put the same code in web.php routes, then it works perfectly. What could be the problem? Is it something in my code? Can it be because of the multi-tenant package i'm using? How would i go about further debugging this?
Can you see if your routes are cached and try clearing that cache. Just clear project route-cache using route:clear
The fix was to group the routes in tenants.php with the web middleware and a namespace:
Route::middleware('web')->namespace('App\Http\Controllers')->group(function() {
//Routes
});
Try composer dump-autoload -o
it helped for me.
After some minutes trying to fix I found the solution.
You don't need to group the routes if you've done in RoutesServiceProvider or in a custom Provider.
Just go to config/tenancy.php and go to routes -> path, Remove the base_path() function and let the string:
'path' => base_path('routes/tenants/tenants.php'),
to
'path' => 'routes/tenants/tenants.php',
And this error should be fixed.
I had a similar error after install laravel/passport 8.1 in Laravel 6.2:
Action Facade\Ignition\Http\Controllers\ExecuteSolutionController not defined.
Fixed it runnig composer update. The result was:
Updating facade/ignition (1.13.0 => 1.13.1):
For people finding this via Google: I had a similar error with Laravel 6.5. I had messed up my AppServiceProvider with an incomplete Git merge:
<?php
namespace App\Providers;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* #return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* #return void
*/
public function boot()
{
<<<<<<< HEAD
Blade::if(
'iscurrentroute',
function ($route) {
$route = Str::replaceFirst(Request::getSchemeAndHttpHost().'/', '', $route);
return Request::is($route);
}
);
=======
Blade::component('components.sortable', 'sortable');
>>>>>>> feature/WLI-58-bedrijf-beheren
}
}
Deleting the "='s", "<'s", and ">'s", and the double use of Blade fixed it for me.
on server side I went to /stoage folder and cleared cashs. E.g. views folder inside that /storage. Then additionally changed all entire folders' and files' permissions to can read and write.
Then pages started show up as expected
I was using the Ignition error pages in Laravel and I have to say that I much prefer the whoops package.
I had the same error reported in this question and by chance changing the error package installed in my app to the whoops one showed me the real error my app was having and I was then instantly able to resolve it. So it seemed that ignition wasn't exactly the cause but it was hindering me resolving another issue.
I implemented email verification in a Laravel 5.7 project I'm working on. I get the email, but whenever I click on the confirm button or even the url provided in the email, I get a 403 forbidden error.
I have searched for several solutions, but haven't been able to find one to this problem. The only reasonable pointers to this error is this github issue https://github.com/laravel/framework/issues/25716 which has been merged and closed by Taylor Otwell by still this problem persists.
Here's the email I get:
Here's the error it throws when I click on the button or the actionUrl at the email footer: and here's the url shown when the 403 page is displayed https://www.mywebsite.com/email/verify/1?expires=1540140119&signature=fd7dc72b05da6f387b2f52a27bceee533b2256436f211930c1319c7a544067da
Please help me. Thank you
Edits: This problem occurs only in production app. On local, this email verification works but throws 403 on production(live) server. My email service is mailgun, and I can access every other email contents relating to the app except completing email verification.
I need help please. Thanks in anticipation
One of the reasons that was in my case can be that you are already logged in with a normal verified user, and you have clicked on the verification email link. In that case it will shoot 403 . Which is not normal in my opinion, but whatever.
For me because manually create verification route. which in laravel 6.x or 7.x The route path for verifying emails has changed. from /email/verify/{id} to /email/verify/{id}/{hash} This probably only happens because I use the rules manually, and not Auth::routes(['verify' => true])
for more information laravel upgrade guide upgrade#email-verification-route-change
This typically occurs if your application is running behind some proxies and probably doesn't handle SSL termination itself.
The solution is to add
protected $proxies = '*';
to the TrustProxies middleware.
Reference: https://laracasts.com/discuss/channels/laravel/hitting-403-page-when-clicking-verify-link-in-email-using-new-laravel-verification-57?page=1
Turns out, this often happens when you have your laravel app running behind a proxy (apache, nginx etc.) We therefore end up replacing laravel's default 'signed' middleware with our own middleware that checks for https:// links. This StackOverFlow answer here was able to fix this problem for me:
Signed route for email verification does not pass signature validation
To use Laravel email verification you must first add the proper routes.
If you take a look at Illuminate/Routing/Router.php you'll see that by default the verify route is disabled.
if($options['verify'] ?? false)
{
$this->emailVerification();
}
To enable your verification routes add the following to your web.php
Auth::routes(['verify'=>true]);
Then run
php artisan route:list
to make sure that it's working.
Check the verify method inside the VerifiesEmails trait,
there they have:
if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) {
throw new AuthorizationException;
}
I have dumped this variable $request->route('hash') and it was null, so I overrided it in the VerificationController:
/**
* Mark the authenticated user's email address as verified.
*
* #param \Illuminate\Http\Request $request
* #return \Illuminate\Http\Response
* #throws \Illuminate\Auth\Access\AuthorizationException
*/
public function verify(Request $request)
{
if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) {
throw new AuthorizationException;
}
if (! hash_equals((string) $request->query('hash'), sha1($request->user()->getEmailForVerification()))) {
throw new AuthorizationException;
}
if ($request->user()->hasVerifiedEmail()) {
return redirect($this->redirectPath());
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect($this->redirectPath())->with('verified', true);
}
And now it works!
The problem for me was my APP_URL had a protocol of http and when I clicked on the verification link NGINX automatically redirected the url from http to https that's why the signature validation failed. I updated the APP_URL to have a protocol of https and that resolved my problem.
My personal experience with this problem was that I set MAIL_DRIVER to log in the .env file, and Laravel escaped special characters (such as &) when it stored the activation link in the log.
So NEVER use the log for MAIL_DRIVER when you have verification email.
(my Laravel version was 5.8).
I have a simple website on Laravel with different types of entries and categories.
I need to create documentation for him.
I tried to install phpDocumentor, but it is not installed on Laravel latest version.
Also I should clarify that this is not the API of the project a simple website.
What other solutions do you have for automatically generating documentation?
If you want to create documentation for routes, you can try laravel-routes.
This package can be installed with composer with the next command:
composer require gussrw/laravel-routes
You can generate the HTML file from the console with the next artisan command.
php artisan route:docs
This command creates an HTML file in Project/docs.
Route description
The description is optional, but if you want to add them create a PHP comment over each route in the web.php file with #description.
/**
* #description Show the home page of the site
*/
Route::get('/home', 'HomeController#index') -> name('home.index');
Resources routes
The descriptions in the resource type routes are identified by their method in the controller.
/**
* #index Show the main view
* #create Show the view to create a photo
* #store Save a photo in database
* #edit Show the view to edit a photo
* #update Update photo data in database
* #destroy Delete a photo in database
*/
Route::resource('photos', 'PhotoController');
Params
Routes params are defined with #param name Description, you can use #param in resource type routes.
/**
* #description Download photo with the photo id.
* #param id ID of the photo in database
*/
Route::get('/photo/{id}/download', 'PhotoController#download');
I'm using Laravel 5.4 and Socialite 3.0
With every new socialite provider I add I get the error:
Driver [provider] not supported.
for example when adding socialiteproviders/twitch 3.0 I will get the error:
Driver [twitch] not supported.
However I can use a provider that's already built in to Socialite, github for example works as expected.
I have tried three different providers and I get the same result each time, what am I doing wrong?
Here are my routes:
Route::get('/auth/bnet', 'BnetController#redirectToProvider');
Route::get('/auth/bnet/return', function() {
$user = Socialite::driver('battlenet')->user();
dd($user->accessTokenResponseBody);
});
Route::get('/auth/git', function() {
return Socialite::driver('github')->redirect();
});
Route::get('/auth/twitch', function() {
return Socialite::with('twitch')->redirect();
});
Here's my $listen from my EventServiceProvider:
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
//'SocialiteProviders\Battlenet\BattlenetExtendSocialite#handle',
'Reflex\SocialiteProviders\BattleNet\BattleNetExtendSocialite#handle',
'SocialiteProviders\Twitch\TwitchExtendSocialite#handle',
],
];
I have added SocialiteProviders\Manager\ServiceProvider::class, to my providers array in app.php, I have added the Socialite facade ('Socialite' => Laravel\Socialite\Facades\Socialite::class,) to my aliases array also in app.php and have added the appropriate keys to my .env
I had the same issue and I found solution.
In config/app.php providers array:
'providers' => [
// ...
Laravel\Socialite\SocialiteServiceProvider::class,
\SocialiteProviders\Manager\ServiceProvider::class,
// ...
]
In app/Providers/EventServiceProvider.php:
protected $listen = [
// ...
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
'SocialiteProviders\VKontakte\VKontakteExtendSocialite#handle',
],
]
You missed \ at start of 'SocialiteProviders\Twitch\TwitchExtendSocialite#handle'.
Hopefully this helps someone, but I found that I had to separate the EventServiceProvider.php listen classes with "\\" instead of "\". Laravel 5.6. e.g:
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
'SocialiteProviders\\Twitch\\TwitchExtendSocialite#handle',
'SocialiteProviders\\Podio\\PodioExtendSocialite#handle',
],
If you're still struggling, triple-check to ensure all of the packages are installed.
I also found that including...
Laravel\Socialite\SocialiteServiceProvider::class,
...in your config/app.php is not necessary when using SocialiteProviders\Manager.
Make sure that you have updated config/services.php to include the client_id client_secret and redirect from your provider.
Clear your config and try again.
Adding an answer here because this question comes up while searching for the same error as it pertains to Lumen as well and I suspect others may run into the same issue that I did.
The Lumen-specific documentation for additional providers doesn't appear to mention some gotchas (at least, for my version of Lumen) and Lumen needs a little extra configuration to work compared to Laravel.
I'm on Lumen 5.8.2 and had been becoming increasingly frustrated getting Socialite with additional providers set up - all of my configuration in bootstrap/app.php and EventServiceProvider.php seemed correct (and was) until I realized that Lumen wasn't actually registering the EventServiceProvider itself.
To remedy this problem, register the EventServiceProvider within your bootstrap/app.php setup:
$app->register(App\Providers\EventServiceProvider::class);
With the EventServiceProvider registered, just refer to the other answers here to configure events, the provider's service config and registering Socialite in app.php and you ought to be good to go.
I had the same issue, to solve it i change the order of my bootstrap/app.php config, try moving the next lines after the Event ServiceProvider:
$app->register(\SocialiteProviders\Manager\ServiceProvider::class);
class_alias(Laravel\Socialite\Facades\Socialite::class, 'Socialite');
//$app->register(Laravel\Socialite\SocialiteServiceProvider::class);
After:
$app->register(App\Providers\EventServiceProvider::class);
My issue was because i declared all the Socialite and SocialiteProvider stuff before.
I'm working with Laravel 4.2 and Mailgun.
The base url of the api of mailgun changed, now it's https://api.mailgun.net/v3/..........
When I perform a request with Laravel it looks like : https://api.mailgun.net/v2/.........
I checked the Facade who handle that :
// vendor/laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php
/**
* Set the domain being used by the transport.
*
* #param string $domain
* #return void
*/
public function setDomain($domain)
{
$this->url = 'https://api.mailgun.net/v2/'.$domain.'/messages.mime';
return $this->domain = $domain;
}
The version is hardcoded ... How I can change that properly ?
Laravel 4.2 was build with mailgun v2. You could probably change v2 to v3 in the code and it would probably work since v3 of mailgun is backwards compatible. (http://blog.mailgun.com/default-api-version-now-v3/) But its not the nicest solution.
You could use an external dependancy like https://github.com/Bogardo/Mailgun that uses mailgun v3 api.
I'd suggest making a code change to the code for the class with the problem, and submitting it back to Laravel's Github as a pull request.
I agree with you that it looks totally hard coded and can't be changed other than doing this, so that seems to be your best bet.
One thing to beware of though: I don't know the mailgun API, but if it's gone from v2 to v3, that implies there have been some breaking changes to the API, so don't think you can just change the number '2' into a '3' and expect it to work; you'll probably also need to change the code that makes the relevant API calls.