Laravel event() not working in production - laravel

im trying to deploy my laravel-project via forge and digitalocean. And while it is working perfectly fine in my local development enviroment, im having a hard time getting the laravel-websockets package running.
So while my "CruiseCrontroller" is functioning perfectly locally, somehow in production is giving me following error.
[2020-12-22 15:42:00] production.ERROR: Class 'App\Events\newRoom' not found {"exception":"[object] (Error(code: 0): Class 'App\\Events\newRoom' not found at /home/forge/default/app/Http/Controllers/CruiseController.php:49)
this is the mentioned line in the CruiseController:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Events\newRoom;
use App\Events\RoomStatusUpdate;
use App\Room;
use App\Sailor;
use Carbon\Carbon;
class CruiseController extends Controller
{
public function newRoom(Request $request){
...
event(new NewRoom($room->channel_id));
}
...
I googled and searched through stackoverflow for 2h now and hope someone here can point me in the right direction. Thank you

Case is important in case sensitive filesystems. You import the following class:
use App\Events\newRoom;
while you should import
use App\Events\NewRoom;
The autoloader tries to find the newRoom.php file and fails to do it because the file with that name doesn't exist.

Related

Laravel / Kakao Class 'App\Http\Controllers\Cache' not found

I try to set up kakao login to my Shopify store, but when I run the test I encountered this message error, what should I do? Thank you
The Cache facade doesn't live in the App\Http\Controllers namespace. If you do not include a use statement at the top of your PHP files for your classes, it is assumed the class does live in the same namespace.
The Laravel Cache facade lives in the Illuminate\Support\Facades namespace so at the top of your KakaoController with your other use statements, add the following:
use Illuminate\Support\Facades\Cache;
You must need to add "use Illuminate\Support\Facades\Cache;" on top of controller, middleware, command, event or blade files.
for example
<?php namespace App\Http\Controllers;
use Illuminate\Support\Facades\Cache;
class KaKaoController extends Controller {
...
or "use \Cache;"

Getting error when trying to add a feed to a user in GetStream

I'm new to GetStream API and have been trying to get it to install with Laravel. I have followed all the documentation on how to install it. However, now that I'm trying to do a simple add to a modal, I get this error.
The error im getting . Here is how my model looks .
Would love some guidance. Thank you!
The ActivityTrait needs to be imported before using it in Want model;
otherwise it's resolved in the current namespace.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use GetStream\StreamLaravel\Eloquent\ActivityTrait;
class Want extends Model {
use ActivityTrait;
#...
}

PHPUnit Error: Call to undefined method Tests\Unit\ExampleTest::visit()

This is the test case I've written and when i try to run it with this command vendor/bin/phpunit on linux it gives me the error "Call to undefined method Tests\Unit\ExampleTest::visit()"
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* #return void
*/
public function testBasicTest()
{
$this->visit('/Login')
->type('KP123#gmail.com','email')
->type('123456','password')
->press('Login')
->seePageIs('/home')
->see('Katy Perry');
}
}
I've tried running composer update and it still could not work. Had Anyone experienced this issue before?
The visit() method looks like it's part of the SeleniumTestCase. So my guess is you either extend from the wrong base class. I assume it should look something like this:
class ExampleTest extends \PHPUnit_Extensions_Selenium2TestCase
{
// your test method
}
edit: I just noticed the Laravel tag, so it's probably more something like Illuminate\Foundation\Testing\TestCase. If this gives you errors that it can't find the class you have to set the bootstrap file in your phpunit.xml to the vendor/autoload.php or another appropriate bootstrap file where the file is registered in the autoloader.
I might have come in late onto this question but here is my 2 cents. I have been trying to use the same methods with my test case which led to a dismal failure.
I the realised that I could actually make use of the TestResponse class which is found on the Foundation namespace that wraps many methods around the response object.
$this->get('/url/to/visit'); //Then you can make your assertions on the returned response.
In my case I had authentication turned on for the application therefore it always complained about the header view where we display the username of the currently logged in user. If you run into that situation then use the Auth Facade like shown below:
\Auth::loginUsingId(1);
You should now be able to assert that your response has some text in it. Hope this helps. By the way I am on Laravel 5.4
If you are using new version of Laravel you must use Laravel Dusk to use similar methods to $this->visit or see. It was excluded from Laravel around version 6.
Instead you can use, but it has limited options:
$this->get('/Login')
composer require laravel/browser-kit-testing --dev
Try this
if you are using > Laravel 8 try :
$this->get('/Login')
instead of visit function, and assertSeeText instead of see

cant create laravel usercontroller

usually when I want to create controller I use php artisan
php artisan make:controller UserController
but in this case I have error in my terminal
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'User' not found
and I wanna use it for users page - update and display users, as well as route
Route::resource('/user', 'UserController');
should I use it like that or something else? and why do I get error?
You get this error because you've used User class somewhere in the code (some controller probably). Find out where did you used it and add this clause to the top of that class:
use App\User;
Or just use full namespace, for example:
\App\User::get();

Upload images in laravel 5

I'm facing a problem in uploading images to server in laravel 5, the problem is some images uploaded normally, and other images breaks the server, and I got this message
The specified URL cannot be found.
I'm using this route in routes.php
Route::any('/{lang}/REGISTER','createAccountController#index');
My class is :
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Foundation\Application;
use App\Http\Requests;
use Request;
use Route;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Lang;
use App\ImageCircleCrop;
class createAccountController extends Controller
{
public function index($lang,Request $request){
// process form data here
}
}
I don't get any error messages in server logs, in fact, the application does not reach the controller code at all. Any help?
New Update: I noticed that the problem occurs just for png images, submitting form with file of type png make a crash on the application. The route does not work after that, and I got the message: "The specified URL cannot be found". Is it something related to the server configuration, or with laravel configration?

Resources