SeedDMS

Ref: https://www.seeddms.org/
Download
NOTE: Don’t download version 5.1.13 because it has a problem with the login but download 5.1.10 (then upgrade to 5.1.13???)
Then modify /home/teddy/Documents/works/seeddms51x/conf/settings.xml

Open via browser and apache2 : http://localhost/works/seeddms51x/seeddms-5.1.10/
user ID: admin
password: admin

Configure VSCode with XDebug

Check if xdebug is already installed: http://localhost:8080/phpinfo.php
Find the config file (ini file) on the above page then open it
<XDEBUG 2.X>

Make sure it’s enabled

Then restart php7.3-fpm service

Check the xdebug properties on the page above: http://localhost:8080/phpinfo.php

Open VSCode then find and install ‘PHP Debug’ extension
</XDEBUG 2.X>

<XDEBUG 3.X>

ALSO FOR THE OTHERS PHP (7.4, 8.0, 8.1, 8.2)

Make sure it’s enabled

Then restart apache2 service

Check the xdebug properties on the page above: http://localhost:8080/phpinfo.php

</XDEBUG 3.X>

Install Flarum on Ubuntu 16.04

Ref: https://flarum.org/
https://flarum.org/docs/install.html

Install via composer:

SETUP NGINX

NGINX SETUP:

CONTENT:

 

Enable file config

 

Register the host on my system

Like this:

 

CHECK THE NGINX SETTING AND RESTART IT:

Change the file permissions

CREATE A NEW DATABASE: flarum COLLATION utf8mb4_unicode_ci
Open it on your browser then install : http://flarum.test
Setting admin:
username: admin
password: Admin@123

User
username: teddy
password: teddy123

Laravel and Swoole

Ref: https://github.com/huang-yi/laravel-swoole-http
My setting:

 

Create a laravel project. I tried version 6.x but I can’t use ‘laravel-swoole-http’ so I installed version 5.6.x

Then go to the dir ‘laravel-swoole’ then install laravel-swoole-http’ with ‘composer require huang-yi/laravel-swoole-http’

then register/publish the swoole service

then start swoole server

open it on your browser: http://127.0.0.1:1215/
the setting in laravel-swoole/config/swoole.php like host (localhost), port (1215), etc
TO stop the swoole server:

ANOTHER ACTIVE LARAVEL SWOOLE (laravel-swooletw)
https://github.com/swooletw/laravel-swoole
PLS READ https://github.com/swooletw/laravel-swoole/wiki
Create a laravel project. I installed version 5.6.x

Then go to the dir ‘laravel-swooletw’ then install laravel-swoole’ with ‘composer require swooletw/laravel-swoole’

from https://github.com/swooletw/laravel-swoole/wiki/4.-Installation,I need to register the swoole service provider in config/app.php

Then need to publish the configuration

Then run the server :

open it on your browser: http://localhost:1215/

ANOTHER LARAVEL – SWOOLE IS
https://github.com/hhxsv5/laravel-s
I download for auction app from https://github.com/GallopYD/domain-spider
STEPS:

CREATE A .env file:

CREATE A NEW DATABASE ‘laravel_auction_swoole’ COLLATION : utf8mb4_unicode_ci
RUN

READ https://github.com/hhxsv5/laravel-s
PUBLISH

START SERVER

OPEN IT ON THE BROWSER : http://localhost:5200/

 

 

Swoolec Loader

Use PHP7.3
Install it if not exist

Use php7.3 as default php

Check

TO ENABLE PHP 7.3 ON NGINX SERVER, PLS DO (MAKE SURE APACHE2 IS STOPPED IF IT’S RUNNING AND START NGINX):

IMPORTANT! ALSO NEED TO INSTALL php7.3-dev. THIS IS NEEDED WHEN I NEED TO COMPILE swoole SOURCE

CHECK php-config SOULD POINT TO php7.3

THE NGINX MAIN CONFIG IN /etc/nginx/nginx.conf
THE DEFAULT VIRTUALHOST IN /etc/nginx/sites-available/default
EDIT IT TO ENABLE PARSING PHP FILE:

Use php7.3-fpm for fastcgi_pass

THEN CHANGE PHP7.3-FPM SETTING:

CHANGE THE CONTENT:

THEN RESTART PHP7.3-FPM SERVICE:

CHECK NGINX SYNTAX: sudo nginx -t
RESTART NGINX: sudo service nginx restart
OPEN IT: http://localhost:8080/phpinfo.php (NEED TO CLEAR THE BROWSER CACHE FIRST)

INSTALL swoole FOR PHP7.3
IF YOU ALREADY INSTALLED IT FOR PHP7.2, YOU NEED TO REMOVE/UNINSTALL IT.
NOTE: TO UNINSTAL IT, USE PHP7.2 VERSION ON TERMINAL NOT PHP7.3
FIRST COMMENT IT from the cli php.ini and php-fpm php.ini files.

THEN

THEN DO THE SAME FOR php-fpm php.ini file (sudo gedit /etc/php/7.2/fpm/php.ini).
USE pecl TO UNINSTALL IT

NOTE: IT’S ALSO IMPORTANT TO DELETE/REMOVE swoole.so FILE IN /usr/lib/php/20170718/swoole.so MANUALLY. BECAUSE PHP7.3 USE EXTENSION DIR IN /usr/lib/php/20180731, MAKE SURE IF ALREADY EXIST swoole.so IN IT. REMOVE IT MANUALLY AS WELL!
NOTE: I TRIED TO INSTALL swoole 4.4.5 FROM SOURCE & COMPILE IT (READ: https://github.com/swoole/swoole-src) BUT ALWAYS FAILED AND GOT THIS ERROR

I THINK THIS IS BECAUSE I MIXED THE INSTALLATION (FROM pecl AND FROM SOURCE) THEN FORGOT TO INSTALL php7.3-dev AND FORGOT TO REMOVE swoole.so MANUALLY IN /usr/lib/php/20180731/swoole.so

THEN INSTALL SWOOLE ON PHP7.3 TERMINAL
MAKE SURE THE PHP API VERSION FOR PHP7.3 IS ‘20180731’ NOT ‘20170718’

Then include the extension “extension=swoole.so” in php.ini file. For php-fpm, the php.ini file in “/etc/php/7.3/fpm/php.ini”

then add this new line:

Save then restart php7.3-fpm service

look it up phpinfo() result. It should show like this:THEN IN CLI

ADD loader73.so FILE.
Copy it manually (USE SUDO) TO php7.3 EXTENSION DIR (IN /usr/lib/php/20180731)

THEN ADD THE EXTENSION ‘loader73.so’ IN php.ini FILE. For php-fpm, the php.ini file in “/etc/php/7.3/fpm/php.ini”

THEN ADD:

PLS DO THE SAME IN php.ini FOR CLI IN /etc/php/7.3/cli/php.ini
THEN RESTART php7.3-fpm SERVICE

CHECK THE EXTENSION IN phpinfo (http://localhost:8080/phpinfo.php)
IT SHOULD SHOW LIKE THISCHECK IN CLI

WE ALSO NEED TO DISABLE xdebug EXTENSION. CHECK IF xdebug IS ENABLED

THEN I NEED TO DISABLE IT.

THEN DISABLE xdebug BY ADDING ‘;’ IN FRONT OF THE LINE LIKE THIS:

THEN RESTART php7.3-fpm SERVICE

MAKE THERE IS NO MORE WARNING ABOUT xdebug

SAMPLE FILES IN /home/teddy/Downloads/Ptcms_V4.2.8 DIR
IN THE DIR, COPY ‘env.example.php’ TO ‘env.php’ FILE
RUN FROM TERMINAL

THEN I GOT ERROR ABOUT MEMCACHE

MAKE SURE memcached SERVICE IS RUNNING

OR

ALSO CHECK IF memcached EXTENSION IS INSTALLED

IF THERE IS NO OUTPUT, THEN INSTALL IT (REF: https://serverpilot.io/docs/how-to-install-the-php-memcache-extension)

HERE IS THE PROCESS

THEN MODIFY /etc/php/7.3/fpm/php.ini AND /etc/php/7.3/cli/php.ini FILE THEN ADD THE EXTENSION extension=memcached.so
THEN RESTART THE SERVICES

 

Install Swoole on Ubuntu 16.04

Ref: https://github.com/swoole/swoole-docs/blob/master/get-started/installation.md
Install from pecl

Then include the extension “extension=swoole.so” in php.ini file. For php-fpm, the php.ini file in “/etc/php/7.2/fpm/php.ini”

then add this new line:

Save then restart php7.2-fpm service

look it up phpinfo() result. It should show like this:Pls do the same thing for php cli. the php.ini file for php cli in “/etc/php/7.2/cli/php.ini”. So edit the file and add a new line for the extension “extension=swoole.so”. Check the extension is loaded on the terminal:

Note: I tried to do this via terminal

But it didn’t work. The extension is not loaded so I put it manually in the php.ini for cli.
NOTE: IT NEED TO DISABLE ‘xdebug’ EXTENSION. CHECK IF xdebug IS ACTIVE/ENABLED:

IF IT IS ENABLED, THEN MODIFY ‘/etc/php/7.2/cli/conf.d/20-xdebug.ini’ FILE TO DISABLE xdebug BY ADDING ‘;’ IN FRONT OF THE LINE LIKE THIS:

IF xdebug IS ENABLED WHEN THE SERVER IS RUNNING, IT’D SPIT THIS WARNING:

TEST SWOOLE
ref: https://github.com/swoole/swoole-docs/blob/master/get-started/examples/tcp_server.md
Create a new file server.php

Run the php in a terminal

then open another terminal and type ‘telnet 127.0.0.1 9501’

The first terminal would print ‘Client : Connect’

You can connect with another new terminal.
To close the connection in the second terminal, press Ctrl + ] then type close in telnet>

The first terminal would give response like this:

Create web server
ref: https://github.com/swoole/swoole-docs/blob/master/get-started/examples/http_server.md
create a new file ‘http_server.php’

then run the server via terminal

Open it via web browser: http://127.0.0.1:9503/
It should show this message:

 

Zend Framework 3: Zend Expressive

Ref: https://docs.zendframework.com/zend-expressive/
https://docs.zendframework.com/zend-expressive/v3/getting-started/quick-start/
Create Login functionality in Expressive 3

Install via composer:

Then go to the project root directory:

Run the project

Then open it on your browser: http://localhost:8080/
NOTE: Make sure no other service running port 8080. If it exist, please stop it. In my composer nginx running port 8080. So I need to stop nginx (sudo service nginx stop).

Create Login
I need to install a few components:

Ok. I want to put the authentication if any visitor want to visit the homepage so he/she need to login first. I need to create a route for this. so modify config/routes.php file like this:

comment the default home route then add a new route like above. If we refresh our browser for the homepage, it’d show this error:

we need to register ‘Zend\Expressive\Authentication\AuthenticationInterface’ under ‘factories’ config in config/autoload/dependencies.global.php.:

If we refresh our browser again, it’d show another error:

So I modify again config/autoload/dependencies.global.php to add ‘Zend\Expressive\Authentication\UserRepositoryInterface’ class in ‘aliases’ config:

When I refresh the browser again. This error would be appear:

So I need to put my database credentials to connect zend expressive to mysql database in config/autoload/local.php file (if this file not exist, please create one):

Please create a new database ‘expressive’ and a new table ‘users’ first. The users table consist of only two fields now. There are username (varchar 100) and password (varchar 100). I put ‘redirect’ value to ‘/login’ so it’d redirect the homepage to login page. Make sure the credentials is correct. If not you’d get an error like this:

Then I refresh my browser again. Another error is coming up:

Here we need ‘Zend\Expressive\Session\SessionMiddleware’ class before routing middleware. So add it in config/pipeline.php:

We fixed those errors until here. When we refresh our browser, we’d get the login page. But the content is showing 404 because we haven’t defined the login page!Create the login form. Add a new file ‘LoginForm.php’ in ‘src/App/Form’ directory. The login form will show username and password fields. The post the form, I’ll put a submit button:

then create a login page handler with inject it with login form with the following factory in src/App/Handler/LoginPageFactory.php:

The LoginPageHandler itself can be initialized in src/App/Handler/LoginPageHandler.php:

Above, we redirect to ‘/’ page when there is a session data as it already authenticated check. We are going to add authentication process next.

The Login form can be as simple as the following in templates/app/login-page.phtml

We can register the LoginPageHandler at App\ConfigProvider::getDependencies() config in src/App/ConfigProvider.php

The routing can be registered as follows with add \Zend\Expressive\Authentication\AuthenticationMiddleware::class for next middleware in config/routes.php:

Until this, when I refresh the browser, I got this error and can’t continue anymore. I still dont know why the error is happened:

I need learn Zend Expressive more!

Composer

I got a fews problem when I tried to check the composer version. A few warnings:

Solution:
ref: https://stackoverflow.com/questions/35874482/cannot-create-cache-directory-or-directory-is-not-writable-proceeding-withou

 

PHP 7.2 FPM AND NGINX

From http://myprojects.advchaweb.com/index.php/2018/06/25/symfony-4-blog-app/

I NEED TO CHECK MY PHP VERSION. CLI ALREADY 7.2.

BUT THE SERVER STILL 7.0 (http://localhost/phpinfo.php).
IF NOT, CHANGE THE PHP-CLI FROM PHP7.0 (FOR EXAMPLE) TO PHP7.2:

I ALREADY HAS 7.2 BUT SOME EXTENSIONS ARE MISSING. SO INSTALL THEM

TO ENABLE PHP 7.2 ON APACHE2 SERVER, PLS DO (MAKE SURE NGINX IS STOPPED IF IT’S RUNNING AND START APACHE2):

TEST: http://localhost/phpinfo.php

IF NEEDED TO CHANGE THE PHP SETTING, PLS EDIT:

TO ENABLE PHP 7.2 ON NGINX SERVER, PLS DO (MAKE SURE APACHE2 IS STOPPED IF IT’S RUNNING AND START NGINX):

THE NGINX MAIN CONFIG IN /etc/nginx/nginx.conf
THE DEFAULT VIRTUALHOST IN /etc/nginx/sites-available/default
EDIT IT TO ENABLE PARSING PHP FILE:

CHANGE THE CONTENT TO ENABLE PHP 7.2 FPM:

THEN CHANGE PHP7.2-FPM SETTING:

CHANGE THE CONTENT:

THEN RESTART PHP7.2-FPM SERVICE:

CHECK NGINX SYNTAX: sudo nginx -t
RESTART NGINX: sudo systemctl restart nginx
OPEN IT: http://localhost/phpinfo.php (NEED TO CLEAR THE BROWSER CACHE FIRST)

Symfony 4 Tutorial

From this:

CREATE SYMFONY 4 PROJECT
(ref: https://symfony.com/doc/current/setup.html –> DONT USE THE INSTRUCTION ‘symfony/website-skeleton’. USE ‘symfony/skeleton’ FROM https://knpuniversity.com/screencast/symfony/setup#play INSTEAD)
1. CREATE A NEW DIR ‘symfony4’ IN Documents/works/ DIR
2. GO INTO IT AND USE ‘composer’ TO CREATE THE PROJECT SKELETON:

TEST IT VIA INTERNAL PHP SERVER:

OPEN VIA BROWSER: http://127.0.0.1:8000/ –> WORKS

CREATE A VIRTUALHOST
1. CREATE A NEW conf FILE

HERE IS THE CONTENT:

2. Enable the site

3. Register the site in /etc/hosts

HERE IS THE CONTENT:

RESTART THE APACHE2 SERVER: sudo systemctl restart apache2
TEST IT VIA BROWSER: http://symfony4test.test/ –> WORKS

ROUTE AND CONTROLLER (ref: https://knpuniversity.com/screencast/symfony/route-controller#play)
Modify /config/routes.yaml FILE TO UNCOMMENT THE CONTENT AND CHANGE THE CONTROLLER AND THE ACTION:

CREATE THE CONTROLLER ‘ArticleController’  FILE AND CLASS. ALSO CREATE ‘homepage’ FUNCTION IN /src/Controller/ArticleController.php:

REFRESH THE BROWSER: http://symfony4test.test/
IT’D SHOW ‘Hello, This is my first page!’ TEXT!

USE ANNOTATION ROUTE (PREFERRED) INSTEAD OF MODIFYING /config/routes.yaml
USE COMPOSER TO INSTALL IT ‘composer require annotations’

BECAUSE WE DONT NEED routes.yaml, COMMENT THE CONTENT BACK (IN /config/routes.yaml):

MODIFY AGAIN /src/Controller/ArticleController.php AND ADD THE ANNOTATION

REFRESH THE BROWSER: http://symfony4test.test/
IT’D SHOW ‘Hello, This is my first page with annotations!’ TEXT!

FANCY WILDCARD ANNOTATION ROUTE
FOR EXAMPLE ADD THIS NEW ROUTE IN /src/Controller/ArticleController.php:

WE SHOULD OPEN IT ON BROWSER LIKE THIS: http://symfony4test.test/news/why-asteroids-taste-like-bacon
BUT I GOT ‘Not found’ ERROR.
OK. I NEED TO RUN ‘composer require apache-pack’

REFRESH BROWSER! –> STILL NOT WORKING
I NEED TO CREATE .htaccess FILE in /public/ DIR (ref: https://knpuniversity.com/screencast/symfony/route-controller#play
AND THE .htaccess CONTENT GOT FROM https://raw.githubusercontent.com/symfony/recipes-contrib/master/symfony/apache-pack/1.0/public/.htaccess):
/public/.htaccess

REFRESH BROWSER: http://symfony4test.test/news/why-asteroids-taste-like-bacon –> WORKS
IT’D PRINT ‘Future page to show one space article!’

USE ANNOTATION WITH PARAMETER
MODIFY /src/Controller/ArticleController.php:

REFRESH BROWSER: http://symfony4test.test/pages/test-page –> WORKS
IT’D PRINT ‘Here is the page “test-page” content!’