(NOTES) NOTES (2023)

Up and running PHP development environment on Linux and Windows.

I'm not a professional PHP developer, I have concentrated to VB.NET, ASP.NET, .NET CORE and so on, but as freelancer I'm time on time can solve various issue even in PHP, for example (2010) Устанавливаем среду разработки PHP.. But currently PHP environment has changed and I want to notice to myself some checkpoint about PHP environment.

Comparing to server Tune PHP environment on server with IIS (as Fast-CGI module) this is more advanced procedure. Firstly, PHP environment is full difference on Linux and Windows. Usually sophisticated PHP program create link dynamically, therefore deployment Linux site on Windows is impossible.



1. Windows PHP environment.

1.1. MySQL.

Ordinary PHP database environment is MySQL, I use it in all my new ASP.NET projects too, so this is a couple screen about MySQL and Workbench installation on Windows.



I'm don't understand idiotic MySQL installation without opportunity to select folder to installation, therefore I always move program to disk D: in order to less uploading disk C:



A lot of sites require special MySql mode:



That's it about MySQL.


1.2. PHP.


Next step is select correct PHP version from https://windows.php.net/download/, I need 7.4 and select PHP VC15 x64 Thread Safe.



In any case developers can add to PHP.INI at list one main parameters "display_errors=on".



That's all about PHP (if we don't need Apache and debugger), it's enough for development.

1.3. Apache.

Otherwise, in some case we also need Apache (this is not need for development environment because PHP has embedded web server).

We can (1) download Apache, (2) Than configure port and root directory, (3) Than install is as service.



If we can any trouble with Apache we need look to log and restart Apache service.



Enable Apache rewriter and turn on it on Apache config.


That's it about Apache.

1.4. VS Code.

Main development tools is VS CODE with special PHP extension. There are a number of PHP extension, I select "All-in-One PHP support - IntelliSense, Debug, Formatter, Code Lenses, Code Fixes, Linting, Refactoring, PHPUnit Tests, Web Server, and more."



We need only one additional tuning of VS Code, set up "runtimeExecutable": "D:\\PhpCli7\\php.exe" to launch.json



This is my VS Code config launch.json

1.5. Add MySQL Access.

If we don't add library with MySQL function we receive error.



Therefore we need to add reference to extension library.



1.6. Debugger.


We can download XDEBUGGER and upload PHPINFO(); to Wizard https://xdebug.org/wizard.



Wizard give us recommendation to library.



Than we can add link this dll to PHP.INI.



Interesting, that place is fixed, if we use "display_errors=on" in PHP.INI than we can see this place.



1.7. Final test.

Firstly we can see Xdebug in PHP.INI and we can see how PHP environment started on embedded PHP server on port 8000.



And of course, main goal of any tuning PHP environment is debugger.



1.8. Debugger's bridge to browser.

There are a couple of bridges from Browser to PHP (like in Angular), it allow set up break, show and change PHP variable directly in Browser, but I don't sure that this bridge working fine as with Angular.



2. Linux PHP environment.

As I mention before, Linux PHP environment is not compatible to Windows PHP environment. But Linux PHP environment is quite simple. But if you install Linux exactly to PHP development, firstly I can take a couple common advice about Linux.

2.1. Setup comfortable Linux environment.

Firstly, usually Windows can booting simple with legacy boot (without UEFI), but with Linux we always need to set up UEFI in BIOS.



Secondary main advice about Linux, we need to delete idiotic Ubuntu desktop manager and replace it to KDE.



And third idiotic default tuning in Ubuntu is languages, for example if I install Ubuntu in Bulgaria and select only English languages, Ubuntu always working with Bulgarian languages.



After KDE installation and delete Bulgarian Languages, I receive my useful environment. I extend desktop to second monitor, delete idiotic energy economy tuning and auto closing computer from myself each 5 minutes (screensaver).



Each next seconds my computer has been more and more comfortable, and next step I install SSH (in order to set up SCP communication from my computer to external world).



Also usually need to initialize GIT.

# git config --global user.name "1111"
# git config --global user.email "[email protected]"

2.2. MySQL.

Including MySQLWorkbench, and by default MySQL Workbench has no right to store password to vault, we need to fix it.



# sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service

And this is process of MySQL installation with creating new user, database schema and uploading data.



And finally we can connect to MySQL with TCP/IP or with socket.



We also can something changing in MySQL, check log and restart MySQL.

# sudo nano /etc/mysql/my.cnf
# sudo service mysql restart
# sudo journalctl -u mysql

Also we can connect to MySQL without Workbench and checking how daemon working.

# sudo ss -tap | grep mysql
# ps xa | grep mysqld
# mysqladmin version
# mysqladmin variables
# mysqladmin --protocol=SOCKET --socket=/tmp/mysql.sock version
# sudo mysqladmin -h 'php-desktop' --port=3306 version

2.3. PHP and PHP debugger.

# sudo add-apt-repository ppa:ondrej/php
# sudo apt update 
# sudo apt install php7.4 

Main issue in PHP installation is by default all packages will installed as last version, at same moment this is PHP 8, but for current project I need 7.4. In this case I made mistake and some modules was installed from PHP8 therefore I delete it.



# sudo apt-get purge php8.*
# php -v

2.4. VS Code.



# sudo apt-get install wget gpg
# wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
# sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
# sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
# rm -f packages.microsoft.gpg
# sudo apt install apt-transport-https
# sudo apt update
# sudo apt install code


2.5. Final result - Debugger.

In first project start I collect all absent modules and add it, for example by default PHP function mysqli_connect() is missing, we need to add this function and all other.

# sudo apt install php7.4-mysqli


2.6. Apache.

If we use Apache need to add to Apache needed module, for example.

# sudo a2enmod php7.4
# sudo a2enmod rewrite
# sudo service apache2 restart




Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: http://www.vb-net.com/Php-2023/Index.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>