Код: Выделить всё
PUSHER_APP_KEY=your_app_key
PUSHER_APP_CLUSTER=mt1
PUSHER_APP_SECRET=your_app_secret
PUSHER_APP_ID=your_app_id
Код: Выделить всё
php artisan env
Код: Выделить всё
<?php
$pusherKey = getenv('PUSHER_APP_KEY'); // Или env('PUSHER_APP_KEY')
$pusherCluster = getenv('PUSHER_APP_CLUSTER'); // Или env('PUSHER_APP_CLUSTER')
echo "Pusher App Key: " . $pusherKey . "\n";
echo "Pusher App Cluster: " . $pusherCluster . "\n";
?>
Код: Выделить всё
php artisan key:generate
Код: Выделить всё
php artisan tinker
Код: Выделить всё
> getenv('PUSHER_APP_KEY')
"your_app_key"
> getenv('PUSHER_APP_CLUSTER')
"mt1"
Код: Выделить всё
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Pusher\Pusher;
class PusherController extends Controller
{
public function index()
{
$appKey = env('PUSHER_APP_KEY');
$appSecret = env('PUSHER_APP_SECRET');
$appId = env('PUSHER_APP_ID');
$appCluster = env('PUSHER_APP_CLUSTER');
if (!$appKey || !$appSecret || !$appId || !$appCluster) {
return response()->json(['error' => 'Missing Pusher configuration'], 500);
}
$pusher = new Pusher(
[
'app_id' => $appId,
'app_key' => $appKey,
'app_secret' => $appSecret,
'cluster' => $appCluster,
'encrypted' => true,
]
);
// ... rest of your code
}
}