This is the final codebase for our Pusher tutorial.
Pusher does Websocket infrastructure so you don't need to. Check us out.
If you don't want to follow the tutorial, and just want to get a local copy up and running, follow these steps.
You will need PHP, Composer and Node.js. For MacOS I recommend installing them with Homebrew. For Windows see instructions for PHP, Composer and Node.
- Get your free Pusher API Keys at https://pusher.com
- Clone this repo
- Install Composer|NPM packages
composer install npm install
- Create a sqlite database file in the database folder
touch db.sqlite
- [OPTIONAL] For UNIX-based systems run these commands below:
# make sure you've driver installed for SQLite sudo apt update sudo apt install php-sqlite3 sudo apt install php7.4-sqlite3 # [optional] or just install for specific PHP version sudo systemctl restart apache2 # one-time command for entire machine sudo usermod -a -G www-data $USER # setup ownerships/permissions sudo chown -R $USER:www-data storage/ bootstrap/cache/ sudo chgrp -R www-data storage bootstrap/cache/ sudo chmod -R ug+rwx storage bootstrap/cache/ # setup SQLite file write permissions for avoiding this error: # SQLSTATE[HY000] General Error: 8 attempt to write a readonly database # NOTE: this will affect not only on "db.sqlite", but on "database" folder recursively sudo chgrp -R www-data database/ chown -R $USER database/ # now you can check appropriate permissions/ownerships # for "database" folder and "database/db.sqlite" file stat -c "%a %n" database/* ls -la database/
- Enter your Pusher credentials in
.env
PUSHER_APP_ID=****** PUSHER_APP_KEY=******************** PUSHER_APP_SECRET=******************** PUSHER_APP_CLUSTER=***
- Enter the path to your database file
DB_DATABASE=<Full path to the sqlite file>
- Initialize the database
php artisan migrate:fresh --seed
- Compile the webpages and run the server
npm run dev php artisan serve
- Login in different browsers (or in incognito) with these credentials:
# browser 1 Username: user1@pusher.com Password: password # browser 2 Username: user2@pusher.com Password: password
- Go to "/chat" for real-time chat
- Want so ask a Pusher a question? Contact support here.
- If you want to raise an issue with our PHP SDK, do it here.
Owned by Pusher.
PusherSwift is released under the MIT license. See LICENSE for details.