afikderi / messenger-app-vuejs-and-laravel Goto Github PK
View Code? Open in Web Editor NEWMessenger Application example using Laravel 5.6 and Vue.JS 2
Messenger Application example using Laravel 5.6 and Vue.JS 2
C:\xampp\htdocs\Messenger-App-VueJS-and-Laravel-master\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php
// want to make sure to convert them back to the raw bytes before encrypting.
if (Str::startsWith($key = $this->key($config), 'base64:')) {
$key = base64_decode(substr($key, 7));
}
return new Encrypter($key, $config['cipher']);
});
}
/**
* Extract the encryption key from the given configuration.
*
* @param array $config
* @return string
*/
protected function key(array $config)
{
return tap($config['key'], function ($key) {
if (empty($key)) {
throw new RuntimeException(
'No application encryption key has been specified.'
);
}
});
}
}
Arguments
"No application encryption key has been specified."
Using Pusher on Laravel 5.8 generates this error on NewMessage Event file.
Steps I took to try and debug:
tried removing the line "use Dispatchable, InteractsWithSockets, SerializesModels;" inside the Class;
tried without using the Classes at the top of the file
none of those worked. On Laravel 5.8 Documentation they don't mention using this line inside our Event Classes, maybe it's outdated?!
File looks like this:
`<?php
namespace StyxEminus\Events;
use StyxEminus\Message;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NewMessage implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Message $message)
{
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('messages.' . $this->message->to);
}
public function broadcastWith() {
return ["message" => $this->message];
}
}
`
Local Server: Apache on Xampp;
Operating System: W10 64bit
Browser: Brave(chromium) & Chrome
Edit: added specs of environment
i follow all step as you (youtube ep02) but i have this error
my code:
NewMessage.php
`namespace App\Events;
use App\Message;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NewMessage implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct(Message $message)
{
$this->message = $message;
}
public function broadcastOn()
{
return new PrivateChannel('messages.' . $this->message->to);
}
public function broadcastWith()
{
return ["message" => $this->message];
}
}`
ContactsController.php
`namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use App\Message;
use App\Events\NewMessage;
class ContactsController extends Controller
{
public function get()
{
$contacts = User::where('id', '!=', auth()->id())->get();
return response()->json($contacts);
}
public function getMessagesFor($id)
{
$messages = Message::where('from', $id)->orWhere('to', $id)->get();
return response()->json($messages);
}
public function send(Request $request)
{
$message = Message::create([
'from' => auth()->id(),
'to' => $request->contact_id,
'text' => $request->text
]);
broadcast(new NewMessage($message));
return response()->json($message);
}
}`
channels.php
Broadcast::channel('messages.{id}', function ($user, $id) { return $user->id === (int) $id; });
Hi Thanks in advance,
Real time message is not working,i am getting the message after refresh the page only.
I’m not receiving messages from others in Real-Time after deploying the chat app to Heroku — unless I click a contact twice.
Is the problem a bug in the code or in heroku? Or how would you deploy this on a live server?
Hello :)
first you did really great job.
However i have one issue. Even i am chatting with somebody messages are still as unread.
Any ideas what is wrong ?
Dear @AfikDeri, first of all, thanks for the tutorial. You are a great teacher.
My app is running like a breeze but the problem is that I already have a pusher app to send notifications.
As I thought, the chat is using those keys to send and receive and this is NOT cool, right?
Ok, I´ve created another app with its own keys. But how to set them up on '.env' file?
I saw this section at '.env' file, but don´t know where to create a MIX pusher app key
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Any hints?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.