Categories
All

Awesome Docker WordPress

Simple and easy containerized WordPress website with docker-compose.

Components used:

  • [image] wordpress:latest
  • [image] mysql:5.7
  • [image] phpmyadmin/phpmyadmin
  • docker
  • docker-compose
  • wget, curl, tar, mysqladmin

Usage

  • $ git clone
  • $ cd awecome-docker-wordpress
  • make sure ports in docker-compose file are opened and not in used
  • make sure no running containers using same ports. delete all containers: $ docker rm $(docker -aq) -f
  • $ sudo ./build.sh
  • Naviagate to:
    website: localhost or 127.0.0.1
    PMA: localhost:5000 or 127.0.0.1:5000

Notes: if you want to use your existing WordPress files remove or comment <<< Download latest wordpress section in build.sh file and put your files in app folder!


GitHub: https://github.com/khaledalam/awesome-docker-wordpress

Categories
All

Simple System With GraphGL, Reactjs, PHP

simple system with GraphQL, Reactjs, PHP

Tools used: PHP v7.3^ , Symfony 4.4^ , React 16^ , VPS, SQL , Docker , overblog/GraphQLBundle

Preview:

as gif – video

note: this is my first time to use GraphQL & Reactjs

GraphiQL:

Example Query:

query {
buyer(id: 20){
id,
name,
authToken
},
products{
id,
name
},
buyers{
name
}
}

Example Mutation: 
Note: entered buyerID and productsIDs must be existed to create order!

mutation {
createOrder(buyerID: "20", productsIDs: ["26", "24"]){
id,
buyer{
name
},
products{
name,
id
}
}
}

Install & run:
  • $ git clone git@github.com:khaledalam/simple-system-with-graphql-react-php.git $ cd simple-system-with-graphql-react-php
  • Update DB info in .env file:DATABASE_URL=mysql://USERNAME:PASSWORD@127.0.0.1:PORT/DB_NAME
  • $ composer install # press (a) to accept all recipes $ yarn install $ php bin/console doctrine:database:create $ php bin/console doctrine:schema:update --force -n $ php bin/console doctrine:fixtures:load -n # add dummy buyers&products
  • $ php bin/console server:start
Assumptions:
  • I assume order can contain multi-products instead of a single product.
  • I assume we can use any ready jwt sandbox app (ex. example)
    • host jwt sandbox on any server
    • inject it throw register, login and retrieving buyer’s orders processes via HTTPexample: – curl -H “Authorization: jwt+[TOKEN]” http://jwt_server/getBuyerIdOfThisToken – compare returnedId with current buyer id – if equal then fetch all current buyer’s orders
  • I assume all current urls available only for admins
  • I assume validations are very basic annotation constraints
  • I assume we use symfony environment (ex. this docker-symfony)
  • I assume more improvements will be done (ex. decrease redundant codes, reducing repetition logic)
  • I assume using another toolkit that supports editing HTTP headers for graphql instead of playground(since I used symfony not laravel and no stable symfony bundle similar to mll-lab/laravel-graphql-playground)

GitHub: https://github.com/khaledalam/simple-system-with-graphql-react-php

Categories
All

Firebase Logger

Firebase Logger is a simple firebase PHP logger package to monitor and save the users activities.

Installation

Use composer to install firebase-logger:
composer require khaledalam/firebase-logger

Preview

Usage

example.php

<?php
// PHP 7.1^
//error_reporting(0);

include_once './FirebaseLogger.php';

$serviceFile = __DIR__ . '/serviceAccountKey.json';
$databaseUri = 'https://{EDIT_THIS}.firebaseio.com';

$firebaseLogger = new FirebaseLogger([
    'service_account_key_json' => $serviceFile,
    'database_uri' => $databaseUri,
    'database_realtime_name' => 'Logger',
]);

if ($_POST['search'])
{
    echo "<h2>Log saved!</h2>";
    $data = [
        'action' => 'search action',
        'value' => $_POST['search'],
    ];
    $firebaseLogger->log($data);
}
?>

<center>
    <form action="./example.php" method="post">
        <input type="text" placeholder="search text" name="search">
        <input type="submit" value="search">
    </form>
</center>

Check the config section in README file and files on GitHub: https://github.com/khaledalam/firebase-logger

Packagist: https://packagist.org/packages/khaledalam/firebase-logger