Skip to content

Commit

Permalink
php8 update
Browse files Browse the repository at this point in the history
  • Loading branch information
ionutgrecu committed Jun 6, 2021
1 parent 6798474 commit b96393e
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class AdminController extends \App\Http\Controllers\Controller
{
function index(){
return view('admin.index');
return view('admin.index', $this->params);
}

function apiCategories(){
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ProductsController extends Controller
{
function index(){
return view('admin.products.index');
return view('admin.products.index', $this->params);
}

}
9 changes: 6 additions & 3 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Controller extends BaseController {

protected $lang;
protected $localeArr;
protected $params=[];
protected $path='';
protected $action='';

function __construct(
ProductCategoriesService $categoryService,
Expand All @@ -52,7 +55,7 @@ function __construct(
View::share('ProductCharacteristicsService', $ProductCharacteristicsService);
View::share('breadcrumbService', $breadcrumbService);

if (Route::current()->parameters['wildcard']) {
if (Route::current()->parameters['wildcard']??null) {
$wildcard = Route::current()->parameters['wildcard'];
$get = explode('/', $wildcard);

Expand All @@ -73,12 +76,12 @@ function __construct(
}
$this->path = implode('/', $pathArr);
}
if (!$this->params[0]) {
if (!($this->params[0]??null)) {
list($controller, $action) = explode('@', Route::currentRouteAction());
$controllerArr = explode('\\', $controller);
$this->params['controller'] = array_pop($controllerArr);
$this->params['action'] = $action;
$this->params[0] = request()->route()->parameters['slug'] ?: ($action == 'page' ? 'index' : $this->action);
$this->params[0] = request()->route()->parameters['slug'] ?? ($action == 'page' ? 'index' : $this->action);
}
$this->params['controller'] = class_basename($this);
$this->params['path'] = $this->path;
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class PagesController extends Controller {

function index() {
// dd($this->data);
$this->data['lang']='ro';
return view('home');
return view('home', $this->params);
}

function about() {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Authenticate extends Middleware {
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo(\Illuminate\Http\Request $request) {
protected function redirectTo($request) {
if (\Request::isJson()) {
return json_encode(['status' => 'not authenticated', 'message' => __('Can\' access that page right now.')]);
} else {
Expand Down
12 changes: 4 additions & 8 deletions app/Models/ProductCharacteristics.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ class ProductCharacteristics extends Model {
protected $fillable = ['val_boolean', 'val_numeric', 'val_short_text', 'val_text'];

public function fill(array $attributes) {
if (is_null($attributes['val_boolean']))
$attributes['val_boolean'] = 0;
if (is_null($attributes['val_numeric']))
$attributes['val_numeric'] = 0;
if (is_null($attributes['val_short_text']))
$attributes['val_short_text'] = '';
if (is_null($attributes['val_text']))
$attributes['val_text'] = '';
$attributes['val_boolean'] = $attributes['val_boolean'] ?? 0;
$attributes['val_numeric'] = $attributes['val_numeric'] ?? 0;
$attributes['val_short_text'] = $attributes['val_short_text'] ?? '';
$attributes['val_text'] = $attributes['val_text'] ?? '';

parent::fill($attributes);
}
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/fortify": "^1.7",
"laravel/framework": "^8.12",
"laravel/framework": "^8.40",
"laravel/tinker": "^2.5"
},
"require-dev": {
Expand Down Expand Up @@ -84,14 +84,14 @@
"@php artisan test"
],
"http": [
"sudo bash -c 'docker kill iqCommerce ; docker rm iqCommerce ; docker build -t iq-php7-laravel docker/http && docker-compose up -d web && chmod -R 0777 storage bootstrap'",
"sudo bash -c 'docker kill iqCommerce ; docker rm iqCommerce ; docker build -t iq-php8-laravel docker/http && docker-compose up -d web && chmod -R 0777 storage bootstrap'",
"if [ -f /usr/bin/kdialog ]; then kdialog --passivepopup \"docker http built\" 15 ; fi",
"bash symlink.sh"
],
"mysql": [
"if [ ! -f docker/mysql/.env ]; then echo \"MYSQL_ROOT_PASSWORD=6zkrHcGh9PTU2PplgbST\" >> docker/mysql/.env && echo \"MYSQL_DATA_FOLDER=$HOME/.mysql/iqCommerce\" >> docker/mysql/.env ; fi",
"mkdir -p $HOME/.mysql/iqCommerce ; chmod 0777 $HOME/.mysql/iqCommerce",
"sudo bash -c 'docker kill iqCommerce iqCommerce-mysql ; docker rm iqCommerce iqCommerce-mysql ; docker build -t iq-php7-laravel docker/http && docker build -t iq-mysql docker/mysql && docker-compose up -d && if grep -L \"mysql.local\" \"/etc/hosts\"; then echo \"mysql.local 127.0.0.1\" >> /etc/hosts ; fi;'",
"sudo bash -c 'docker kill iqCommerce iqCommerce-mysql ; docker rm iqCommerce iqCommerce-mysql ; docker build -t iq-php8-laravel docker/http && docker build -t iq-mysql docker/mysql && docker-compose up -d && if grep -L \"mysql.local\" \"/etc/hosts\"; then echo \"mysql.local 127.0.0.1\" >> /etc/hosts ; fi;'",
"echo \"Waiting for mysql to warm up\" ; sleep 15 ; mysql -uroot -p6zkrHcGh9PTU2PplgbST -P 3301 -h 127.0.0.1 -e \"CREATE DATABASE IF NOT EXISTS iqCommerce\"",
"if [ -f /usr/bin/kdialog ]; then kdialog --passivepopup \"docker mysql built\" 15 ; fi",
"bash symlink.sh"
Expand Down
64 changes: 32 additions & 32 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.3'
services:
web:
image: iq-php7-laravel
image: iq-php8-laravel
container_name: iqCommerce
#tty: true
#stdin_open: true
Expand Down
18 changes: 9 additions & 9 deletions docker/http/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ LABEL Maintainer="Ionut Grecu <[email protected]>" \
Description="Lightweight container with Nginx 1.18 & PHP-FPM 7.4 based on Alpine Linux. Fork from https://hub.docker.com/r/trafex/alpine-nginx-php7/dockerfile and inspired from https://hub.docker.com/r/lorisleiva/laravel-docker/dockerfile"

# Install packages and remove default server definitionzip
RUN apk --no-cache add openssl util-linux php7 php7-fpm php7-opcache php7-mysqli php7-json php7-memcached php7-openssl php7-common php7-curl php-pdo php-pdo_mysql \
php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session php7-zip php7-bcmath \
php7-mbstring php7-gd php7-calendar php7-exif php7-iconv php7-pcntl php7-tokenizer php7-fileinfo \
RUN apk --no-cache add openssl util-linux php8 php8-fpm php8-opcache php8-mysqli php8-json php8-pecl-memcached php8-openssl php8-common php8-curl php8-pdo php8-pdo_mysql \
php8-zlib php8-xml php8-phar php8-intl php8-dom php8-xmlreader php8-ctype php8-session php8-zip php8-bcmath \
php8-mbstring php8-gd php8-calendar php8-exif php8-iconv php8-pcntl php8-tokenizer php8-fileinfo \
nginx composer yarn git supervisor curl nano sudo && \
rm /etc/nginx/conf.d/default.conf

Expand All @@ -17,12 +17,12 @@ COPY config/nginx.conf /etc/nginx/nginx.conf
RUN chmod 0755 /etc/nginx/nginx.conf

# Configure PHP-FPM
COPY config/fpm-pool.conf /etc/php7/php-fpm.d/www.conf
RUN chmod 0755 /etc/php7/php-fpm.d/www.conf
COPY config/php.ini /etc/php7/conf.d/custom.ini
RUN chmod 0755 /etc/php7/conf.d/custom.ini
COPY config/20-opcache.ini /etc/php7/conf.d/20-opcache.ini
RUN chmod 0755 /etc/php7/conf.d/20-opcache.ini
COPY config/fpm-pool.conf /etc/php8/php-fpm.d/www.conf
RUN chmod 0755 /etc/php8/php-fpm.d/www.conf
COPY config/php.ini /etc/php8/conf.d/custom.ini
RUN chmod 0755 /etc/php8/conf.d/custom.ini
COPY config/20-opcache.ini /etc/php8/conf.d/20-opcache.ini
RUN chmod 0755 /etc/php8/conf.d/20-opcache.ini

# Configure supervisord
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
Expand Down
4 changes: 2 additions & 2 deletions docker/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Repository: https://[email protected]/websea/wd-php7-laravel.git

## Build

docker build -t iq-php7-laravel
docker build -t iq-php8-laravel

## Usage

Start the Docker container:

docker run -p 10000:8080 iq-php7-laravel
docker run -p 10000:8080 iq-php8-laravel

See the PHP info on http://localhost:10000, or the static html page on http://localhost/test.html

Expand Down
10 changes: 5 additions & 5 deletions docker/http/config/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ logfile_maxbytes=0
pidfile=/run/supervisord.pid

[program:php-fpm]
command=php-fpm7 -F
command=php-fpm8 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
Expand All @@ -22,7 +22,7 @@ stderr_logfile_maxbytes=0
autorestart=false
startretries=0

[program:cron]
command=/bin/sh /var/www/html/cron.sh
autostart=true
autorestart=true
#[program:cron]
#command=/bin/sh /var/www/html/cron.sh
#autostart=true
#autorestart=true
Loading

0 comments on commit b96393e

Please sign in to comment.