ThePenzone.com blog - A Laravel 5.6 blog application with Docker, Redis and Socket.io
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 51 commits ahead, 65 commits behind guillaumebriday:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
bootstrap
config
database
lib/capistrano/tasks
provisioning
public
resources
routes
storage
tests
.dockerignore
.env.example
.env.testing
.env.travis
.gitattributes
.gitignore
.php_cs
.travis.yml
Capfile
Gemfile
Gemfile.lock
LICENSE
artisan
composer.json
composer.lock
destroy.sh
docker-compose.yml
laravel-echo-server.json
package-lock.json
package.json
phpunit.xml
readme.md
server.php
startup.sh
webpack.mix.js
yarn.lock

readme.md

ThePenzone.com blog repository

The source for the blog ThePenzone.com, repo hosted at https://github.com/tompenzer/penzone. Largely a fork of https://github.com/guillaumebriday/laravel-blog, with the front-end package manager changed from NPM to Yarn, user self-registration disabled, social features (comments, liking) disabled, some additions to user profiles, and added contact form functionality. There are also some changes made to the Docker provisioning to facilitate production deployment to Amazon ECS and other Docker hosting providers.

Installation

Development environment requirements:

  • Git - on Mac, you will be prompted to install the CLI dev tools including git upon attempting to git clone in the command below if you don't already have it installed.
  • Docker

Clone the repo and start up the development environment using the terminal on your local machine:

$ git clone git@github.com:tompenzer/penzone.git
$ cd penzone
$ ./startup.sh

Note - potential sql error

If you get a DB PDO error at the end of the startup process, try connecting to the docker mysql image server with any SQL client (i.e. Sequel Pro if you're on a Mac), with the following credentials:

host: 0.0.0.0
port: 3306
user: root
pass: secret

And then try running the database migrations manually:

$ docker-compose run --rm blog-server php artisan migrate --seed

This will create the default admin user that you can use to sign in.

Usage

The dev env site should be accessible in your web browser at the following URL:

http://localhost:8000

You can use the following credentials to log in, so you can create users and posts:

Email: admin@example.com
Password: admin

You can use the admin dashboard section to configure users and content:

http://localhost:8000/admin/dashboard

Cleaning up and stopping the dev environment

To have docker take down the server container, wipe the built docker images, and erase the database cache, ensuring a fresh build next time, run the following command from inside the project directory:

$ ./destroy.sh

MediaLibrary - Local vs Amazon S3 storage

The .env.example file is currently configured to use local storage for the MediaLibrary component (used for image gallery creation, attachment to users, posts). If you would prefer to store media in Amazon s3, you can set the MEDIALIBRARY_FILESYSTEM_DRIVER key to s3 in the appropriate .env file(s).

Building blog server Docker image

An example of building the blog server docker image for this project, with tags for a version 1.0.0/latest release:

$ docker build -f provisioning/blog_server/development/Dockerfile -t tompenzer/penzone:1.0.0 -t tompenzer/penzone:latest -t tompenzer/penzone:1 -t tompenzer/penzone:1.0 .

Starting the docker environment in production Mode

If you pass the word production as an argument to startup.sh, it'll build the front-end in production mode and skip DB migrations:

$ ./startup.sh production

Deploying to production

See the readme.md file in the provisioning directory for instructions on production deployment.

ReadMe from guillaumebriday/laravel-blog including API documentation follows:

Laravel 5.6 blog

Build Status Donate

The purpose of this repository is to show good development practices on Laravel as well as to present cases of use of the framework's functionalities like :

Beside Laravel, this project uses other tools like :

Some screenshots

You can find some screenshots of the application on : https://imgur.com/a/Jbnwj

Installation

Development environment requirements :

Setting up your development environment on your local machine :

$ git clone https://github.com/guillaumebriday/laravel-blog.git
$ cd laravel-blog
$ cp .env.example .env
$ docker-compose run --rm --no-deps blog-server composer install
$ docker-compose run --rm --no-deps blog-server php artisan key:generate
$ docker run --rm -it -v $(pwd):/app -w /app node npm install
$ docker-compose up -d

Now you can access the application via http://localhost:8000.

There is no need to run php artisan serve. PHP is already running in a dedicated container.

Before starting

You need to run the migrations with the seeds :

$ docker-compose run --rm blog-server php artisan migrate --seed

This will create a new user that you can use to sign in :

Email : darthvader@deathstar.ds
Password : 4nak1n

And then, compile the assets :

$ docker run --rm -it -v $(pwd):/app -w /app node npm run dev

Useful commands

Seeding the database :

$ docker-compose run --rm blog-server php artisan db:seed

Running tests :

$ docker-compose run --rm blog-server ./vendor/bin/phpunit

Running php-cs-fixer :

$ docker-compose run --rm --no-deps blog-server ./vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --dry-run --diff

Generating backup :

$ docker-compose run --rm blog-server php artisan backup:run

Generating fake data :

$ docker-compose run --rm blog-server php artisan db:seed --class=DevDatabaseSeeder

Starting job for newsletter :

$ docker-compose run blog-server php artisan tinker
> App\Jobs\PrepareNewsletterSubscriptionEmail::dispatch();

Discover package

$ docker-compose run --rm --no-deps blog-server php artisan package:discover

In development environnement, rebuild the database :

$ docker-compose run --rm blog-server php artisan migrate:fresh --seed

Accessing the API

Clients can access to the REST API. API requests require authentication via token. You can create a new token in your user profil.

Then, you can use this token either as url parameter or in Authorization header :

# Url parameter
GET http://laravel-blog.app/api/v1/posts?api_token=your_private_token_here

# Authorization Header
curl --header "Authorization: Bearer your_private_token_here" http://laravel-blog.app/api/v1/posts

API are prefixed by api and the API version number like so v1.

Do not forget to set the X-Requested-With header to XMLHttpRequest. Otherwise, Laravel won't recognize the call as an AJAX request.

To list all the available routes for API :

$ docker-compose run --rm --no-deps blog-server php artisan route:list --path=api

Broadcasting & WebSockets

Before using WebSockets, you need to set the BROADCAST_DRIVER in your .env file for Redis :

BROADCAST_DRIVER=redis

More details

More details are available or to come on Guillaume Briday's blog (French).

Contributing

Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.

License

This project is released under the MIT license.