Libraries (PHP): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 152: Regel 152:
 
* <code>/Dropbox/Overhead/Scripts/php/dvb_db_functions.php</code>
 
* <code>/Dropbox/Overhead/Scripts/php/dvb_db_functions.php</code>
 
* <code>/Dropbox/Overhead/Scripts/php/dvb_wordpress_functions.php</code>.
 
* <code>/Dropbox/Overhead/Scripts/php/dvb_wordpress_functions.php</code>.
 +
 +
In april 2021 heb ik de paden licht gewijzigd:
 +
 +
* <code>/Dropbox/Overhead/Scripts/php-library-dvb/dvb_db_functions.php</code>
 +
* <code>/Dropbox/Overhead/Scripts/php-library-dvb/dvb_wordpress_functions.php</code>.
 +
 +
Overigens: Er wordt dus ''niets'' opgeslagen in mappen buiten Dropbox, zoals </code>/opt</code> or whatever - Behalve misschien op servers?
  
 
== Zie ook ==
 
== Zie ook ==

Versie van 26 apr 2021 11:25

Third-party bibliotheken

Belangrijkste commando's rondom bibliotheken:

  • include [1]
  • require [2]
  • Libraries kun je meestal mbv. apt install binnenhengelen
  • Zie PHP installeren voor meer!

Casus: SoapClient (april 2019)

Windows: dll uit-commentariseren in php.ini. Linux (misschien de verkeerde library: Soap ipv. SoapClient?) [3]:

sudo apt-get install php7.0-soap 
sudo systemctl restart apache2

Debuggen (Bash)

Commando

php -i | grep -i soap

Geeft:

/etc/php/7.0/cli/conf.d/20-soap.ini,
soap
Soap Client => enabled
Soap Server => enabled
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400

Handig: Je ziet dat ik inderdaad de CLI-variant gebruik op dit moment.

Commando

apt-cache search php | grep -i soap

toont een overzicht van beschikbare apt-downloads met de term soap in de titel. Uitkomst:

libnusoap-php - SOAP toolkit for PHP
php-soap - SOAP module for PHP [default]
php7.0-soap - SOAP module for PHP
python-pysimplesoap - simple and lightweight SOAP Library (Python 2)
python3-pysimplesoap - simple and lightweight SOAP Library (Python 3)

Bron: https://stackoverflow.com/questions/11584426/how-do-i-enable-enable-soap-in-php-on-linux - Geweldig!

Verifiëren welke modules enabled zijn:

php -m


[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

Casus: Installatie GD (nov. 2019)

sudo apt install php-gd

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libtiff5 libwebp6
  libxpm4 php7.2-gd
Suggested packages:
  libgd-tools
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libtiff5 libwebp6
  libxpm4 php-gd php7.2-gd
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 1892 kB of archives.
After this operation, 6237 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

...

+ herstarten van Apache (a2re)

Resultaat

Soap en/of SoapClient bleek gewoon actief te zijn en hoefde niet apart geladen te worden met require oid. - Het was weer eens gemakkelijker dan ik dacht.

Eigen bibliotheken

Ik gebruik WordPress bijna alleen in combinatie met de PHP-API. Tot ca. 2018 plaatste ik functies die ik wilde hergebruiken, in het standaard WordPress-bestand functions.php. Rond 2019 ben ik daar vanafgestapt en gebruikte ik twee bestanden met functies:

  • /Dropbox/Overhead/Scripts/php/dvb_db_functions.php
  • /Dropbox/Overhead/Scripts/php/dvb_wordpress_functions.php.

In april 2021 heb ik de paden licht gewijzigd:

  • /Dropbox/Overhead/Scripts/php-library-dvb/dvb_db_functions.php
  • /Dropbox/Overhead/Scripts/php-library-dvb/dvb_wordpress_functions.php.

Overigens: Er wordt dus niets opgeslagen in mappen buiten Dropbox, zoals /opt or whatever - Behalve misschien op servers?

Zie ook