Skip to content

Commit 09d149c

Browse files
first commit
0 parents  commit 09d149c

File tree

109 files changed

+13586
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+13586
-0
lines changed

.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
],
5+
"plugins": [
6+
"@babel/plugin-syntax-dynamic-import",
7+
"@babel/plugin-proposal-class-properties"
8+
]
9+
}

.docker/db/data/.gitkeep

Whitespace-only changes.

.docker/db/log/.gitkeep

Whitespace-only changes.

.docker/install-php.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
3+
apk add bzip2 file re2c freetds freetype icu libintl libldap libjpeg libmcrypt libpng libpq libwebp libzip nodejs npm
4+
5+
TMP="autoconf \
6+
bzip2-dev \
7+
freetds-dev \
8+
freetype-dev \
9+
g++ \
10+
gcc \
11+
gettext-dev \
12+
icu-dev \
13+
jpeg-dev \
14+
libmcrypt-dev \
15+
libpng-dev \
16+
libwebp-dev \
17+
libxml2-dev \
18+
libzip-dev \
19+
make \
20+
openldap-dev \
21+
postgresql-dev"
22+
23+
apk add $TMP
24+
25+
# Configure extensions
26+
docker-php-ext-configure gd --with-jpeg-dir=usr/ --with-freetype-dir=usr/ --with-webp-dir=usr/
27+
docker-php-ext-configure ldap --with-libdir=lib/
28+
docker-php-ext-configure pdo_dblib --with-libdir=lib/
29+
30+
docker-php-ext-install \
31+
bz2 \
32+
exif \
33+
gd \
34+
gettext \
35+
intl \
36+
ldap \
37+
pdo_dblib \
38+
pdo_pgsql \
39+
xmlrpc \
40+
zip \
41+
mysqli \
42+
pdo_mysql
43+
44+
# Install Xdebug
45+
# mac : docker.for.mac.localhost / win : host.docker.internal
46+
pecl install xdebug-3.0.2
47+
echo "" >> /var/log/xdebug.log && chmod 777 /var/log/xdebug.log && echo -e "xdebug.log_level=1 \n xdebug.log=/var/log/xdebug.log \n zend_extension = xdebug.so \n xdebug.idekey=PHPSTORM \n xdebug.discover_client_host=0 \n xdebug.default_enable = 1 \n xdebug.remote_handler = "dbgp" \n xdebug.remote_port=9002 \n xdebug.client_host="host.docker.internal" \n xdebug.client_port=9002 \n xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini
48+
49+
# Install composer
50+
cd /tmp && php -r "readfile('https://getcomposer.org/installer');" | php && \
51+
mv composer.phar /usr/bin/composer && \
52+
chmod +x /usr/bin/composer
53+
54+
# apk del $TMP
55+
56+
# Install PHPUnit
57+
curl -sSL -o /usr/bin/phpunit https://phar.phpunit.de/phpunit.phar && chmod +x /usr/bin/phpunit
58+
59+
# Set timezone
60+
#RUN echo Asia/Karachi > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata

.docker/nginx.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server {
2+
listen 8080;
3+
index index.php index.html;
4+
error_log /var/log/nginx/api-error.log;
5+
access_log /var/log/nginx/api-access.log;
6+
root /var/www/app/public;
7+
location ~ \.php$ {
8+
try_files $uri =404;
9+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
10+
fastcgi_pass lr_app:9000;
11+
fastcgi_index index.php;
12+
include fastcgi_params;
13+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
14+
fastcgi_param PATH_INFO $fastcgi_path_info;
15+
}
16+
location / {
17+
try_files $uri $uri/ /index.php?$query_string;
18+
gzip_static on;
19+
}
20+
}

.docker/php.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
upload_max_filesize=40M
2+
post_max_size=40M
3+
memory_limit = -1

.env.docker

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
APP_ENV=test
2+
APP_KEY=key
3+
APP_DEBUG=true
4+
APP_LOG_LEVEL=debug
5+
APP_URL=http://localhost:8100
6+
7+
DB_CONNECTION=mysql
8+
DB_HOST=lr_database
9+
DB_PORT=3306
10+
DB_DATABASE=laravel_crud_boilerplate
11+
DB_USERNAME=tester
12+
DB_PASSWORD=test1235
13+
14+
BROADCAST_DRIVER=log
15+
CACHE_DRIVER=file
16+
SESSION_DRIVER=file
17+
QUEUE_DRIVER=sync
18+
19+
REDIS_HOST=127.0.0.1
20+
REDIS_PASSWORD=null
21+
REDIS_PORT=6379
22+
23+
MAIL_DRIVER=smtp
24+
MAIL_HOST=mailtrap.io
25+
MAIL_PORT=2525
26+
MAIL_USERNAME=null
27+
MAIL_PASSWORD=null
28+
MAIL_ENCRYPTION=null
29+
30+
PUSHER_APP_ID=
31+
PUSHER_APP_KEY=
32+
PUSHER_APP_SECRET=
33+
34+
PERSONAL_CLIENT_ID=1
35+
PERSONAL_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
36+
PASSWORD_CLIENT_ID=2
37+
PASSWORD_CLIENT_SECRET=bmKYzw31L1BJc5EqjL1MY1yfVtfET3Ezg4iIzGhD

.env.travis

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
APP_ENV=testing
2+
APP_KEY=SomeRandomString
3+
4+
DB_CONNECTION=testing
5+
DB_TEST_USERNAME=root
6+
DB_TEST_PASSWORD=
7+
8+
CACHE_DRIVER=array
9+
SESSION_DRIVER=array
10+
QUEUE_DRIVER=sync

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/public

.eslintrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
env: {
7+
browser: true,
8+
node: true,
9+
es6: true,
10+
},
11+
globals: {
12+
React: true
13+
},
14+
parserOptions: {
15+
ecmaFeatures: {
16+
jsx: true
17+
}
18+
},
19+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
20+
extends: ["eslint:recommended", "plugin:react/recommended"],
21+
// required to lint *.vue files
22+
plugins: [
23+
'html', 'react'
24+
],
25+
// add your custom rules here
26+
'rules': {
27+
// allow paren-less arrow functions
28+
'arrow-parens': 0,
29+
// allow async-await
30+
'generator-star-spacing': 0,
31+
}
32+
}

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/node_modules
2+
/storage/*.key
3+
/vendor
4+
/.idea
5+
Homestead.json
6+
Homestead.yaml
7+
.env
8+
_ide_helper.php
9+
10+
/public/storage
11+
/public/hot
12+
/public/js/
13+
/public/css/
14+
/public/fonts/
15+
/public/mix-manifest.json
16+
/*.log
17+
/public/*.js
18+
/public/*.js.map
19+
20+
/.docker/db/data/*
21+
!/.docker/db/data/.gitkeep
22+
23+
/.docker/db/log/*
24+
!/.docker/db/log/.gitkeep

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":1256:{a:2:{s:7:"defects";a:7:{s:74:"Tests\Feature\ArticleTest::that_only_loading_articles_for_provided_user_id";i:4;s:49:"Tests\Feature\ArticleTest::that_load_all_articles";i:4;s:62:"Tests\Feature\ArticleTest::that_loaded_only_published_articles";i:4;s:59:"Tests\Feature\ArticleTest::that_load_only_published_article";i:4;s:95:"Tests\Feature\ArticleTest::that_article_get_published_and_total_number_of_published_get_changed";i:4;s:99:"Tests\Feature\ArticleTest::that_article_get_unpublished_and_total_number_of_unpublished_get_changed";i:4;s:44:"Tests\Feature\LoginTest::test_user_can_login";i:3;}s:5:"times";a:8:{s:74:"Tests\Feature\ArticleTest::that_only_loading_articles_for_provided_user_id";d:1.668;s:49:"Tests\Feature\ArticleTest::that_load_all_articles";d:0.541;s:62:"Tests\Feature\ArticleTest::that_loaded_only_published_articles";d:0.376;s:59:"Tests\Feature\ArticleTest::that_load_only_published_article";d:0.556;s:95:"Tests\Feature\ArticleTest::that_article_get_published_and_total_number_of_published_get_changed";d:0.438;s:99:"Tests\Feature\ArticleTest::that_article_get_unpublished_and_total_number_of_unpublished_get_changed";d:0.419;s:44:"Tests\Feature\LoginTest::test_user_can_login";d:1.037;s:37:"Tests\Unit\ExampleTest::testBasicTest";d:0.21;}}}

.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
language: php
2+
3+
php:
4+
- 7.3
5+
6+
before_script:
7+
- cp .env.travis .env
8+
- composer self-update
9+
- composer install --no-interaction
10+
- php artisan key:generate
11+
- php artisan migrate --no-interaction --verbose
12+
- php artisan passport:configure
13+
14+
before_install:
15+
- mysql -e 'CREATE DATABASE testing;'
16+
17+
script:
18+
- ./vendor/bin/phpunit
19+
20+
services:
21+
- mysql
22+
23+
cache:
24+
directories:
25+
- vendor
26+
27+
branches:
28+
only:
29+
- master

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM php:7.4-fpm-alpine
2+
3+
# Comment this to improve stability on "auto deploy" environments
4+
RUN apk update && apk upgrade
5+
6+
# Install basic dependencies
7+
RUN apk -u add bash git
8+
9+
# Install PHP extensions
10+
ADD ./.docker/install-php.sh /usr/sbin/install-php.sh
11+
RUN chmod +x /usr/sbin/install-php.sh
12+
# [WARNING] Although the following script fails, this building process does NOT stop.
13+
RUN /usr/sbin/install-php.sh
14+
15+
# Copy existing application directory contents
16+
COPY ./.docker/*.ini /usr/local/etc/php/conf.d/
17+
#COPY . .
18+
19+
# Expose ports and start php-fpm server
20+
EXPOSE 9000
21+
22+
ENTRYPOINT if [ ! -d 'vendor' ]; then composer install; fi && php artisan key:gen && chgrp -R www-data ./ && chmod -R 775 bootstrap/cache/ storage/ && composer dump-autoload && php artisan config:clear && php-fpm

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<p align="center"><img src="https://laravel.com/assets/img/components/logo-laravel.svg"></p>
2+
3+
## Laravel 8 and React 17 boilerplate
4+
There are two different ways to run this demo
5+
6+
Please follow the guide.
7+
8+
## Prerequisite
9+
10+
1. Make sure you have [composer](https://getcomposer.org/download/) installed.
11+
2. Make sure you have latest stable version of [node](https://nodejs.org/en/download/) installed.
12+
13+
### Option 1
14+
15+
1. `git clone`
16+
2. `create a .env file copy content from .env.example and update the values`
17+
3. `composer install && composer update`
18+
4. `php artisan cron:refresh-database`
19+
5. if npm version < 7 `npm install && npm run dev` else `npm install --legacy-peer-deps && npm run dev`
20+
6. `php artisan key:gen`
21+
7. `php artisan serve`
22+
23+
### Option 2
24+
25+
## Prerequisite
26+
Make sure you have [docker](https://docs.docker.com/install/) and [docker-compose](https://docs.docker.com/compose/install/) installed on you machine.
27+
28+
1. `git clone`
29+
2. `create a .env file copy content from .env.docker and do not make any change`
30+
31+
run following command in terminal / power shell
32+
```
33+
docker-compose up -d
34+
```
35+
36+
when docker will finish building the containers, access the "laravel-crud-boilerplate-app" container using following command
37+
38+
`docker exec -it lr_app sh`
39+
40+
now you will be inside container
41+
42+
run following commands
43+
1. `composer install && composer update`
44+
2. `php artisan cron:refresh-database`
45+
3. `php artisan key:gen`
46+
4. if npm version < 7 `npm install && npm run dev` else `npm install --legacy-peer-deps && npm run dev`
47+
48+
open browser and check the following address
49+
50+
`http://localhost:8100`
51+
52+
TODO:
53+
54+
- [x] Add Redux
55+
- [x] Add Laravel Sanctum for authentication
56+
- [x] User Login
57+
- [x] User Register
58+
- [x] Users Crud
59+
- [x] Articles Crud
60+
- [x] Form validation Client and Server
61+
- [x] Reset Password
62+
- [x] Tests
63+
- [x] Upgrade to Laravel 7
64+
- [x] Upgrade to React 16.13
65+
- [x] docker
66+
67+
68+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class RefreshDatabase extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'cron:refresh-database';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Refresh database to remove user changes from production server';
22+
23+
/**
24+
* Execute the console command.
25+
*
26+
* @return void
27+
*/
28+
public function handle(): void
29+
{
30+
$this->call('migrate:refresh');
31+
$this->call('db:seed');
32+
}
33+
}

0 commit comments

Comments
 (0)