
This is a simple blog project, mainly used to help me learn about Laravel. The entire project uses the TALL stack, which is:
This project contains certain basic functions, such as membership system, writing articles and replies.
Post editor use CKEditor 5, You can upload image to AWS S3 in blog post. You can search post by Algolia.
Clone the repository to your local machine:
git clone https://github.com/YilanBoy/docfunc.gitChange the current working directory to the repository:
cd docfuncInstall the composer package:
composer installInstall the npm package:
npm installRunning laravel mix:
npm run devCreate the .env file, and set up the config, such as database connection, reCAPTCHA key, S3 key, mail service etc.:
cp .env-example .envGenerate application key (for session and cookie encryption):
php artisan key:generateRunning migrations command to generate the database schema:
php artisan migrateGenerate ide-helper:
php artisan ide-helper:generateGenerate model ide-helper:
php artisan ide-helper:modelsYou could deploy this project use Laravel Octane, supercharges the performance by serving application using Swoole, RoadRunner, or FrankenPHP.
Note
If you want to use swoole server, you must install swoole extension first.
Using PECL to install swoole extension:
pecl install swooleUsing package manager to install swoole extension (Linux):
sudo add-apt-repository ppa:ondrej/php
sudo apt-get php8.2-swooleSetting octane in .env file:
OCTANE_SERVER=swoole
OCTANE_HTTPS=false
Start the service by swoole server:
php artisan ocatane:startIn production, you can use Supervisor to start swoole server and laravel queue worker.
Using supervisor to start swoole server process,
we have to create a docfunc-octane-worker.conf config file in /etc/supervisor/conf.d/.
[program:docfunc-octane-worker]
command=/usr/bin/php -d variables_order=EGPCS /var/www/docfunc/artisan octane:start --workers=2 --server=swoole --host=0.0.0.0 --port=8000
user=www-data
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=/var/log/docfunc-octane-worker.log
Using supervisor to start laravel queue worker process,
we have to create a docfunc-queue-worker.conf config file in /etc/supervisor/conf.d/.
[program:docfunc-queue-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/docfunc/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stopwaitsecs=3600
stdout_logfile=/var/log/docfunc-queue-worker.log
Set crontab to run Laravel Task Schedule.
Editing crontab.
crontab -eAdd this line to run the Scheduler.
0 * * * * cd /var/www/docfunc && php artisan schedule:run >> /dev/null 2>&1