in php.ini, uncomment extension=curl Some timese you may neet to download cacert.pem which must be set curl.cainfo = "C:\wamp64\bin\php\php7.4.9\extras\ssl\cacert.pem" Test Code <?php error_reporting(-1);// report all errors $ch = curl_init(); $curlConfig = array( CURLOPT_URL => "https://www.outsource-online.net/", CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => array( 'field1' => 'some date', 'field2' => 'some other data', ) );…
Category: Miscellaneous(PHP)
OAuth2 workflow Google documentation on OAuth2 , see also Token Types Client Libraries Source of the above image is linked to the above image Workflow for serverside applications in Google Site PS: To view all accesses granted to all google apps, visit Google Security Checkup Web and App Activity Steps to integrate Google Login Create…
Addendum to Ensuring Unique ession ID Steps Create tables DROP TABLE IF EXISTS `sessions_with_db`; CREATE TABLE IF NOT EXISTS `sessions_with_db` ( `id` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `access` datetime NOT NULL, `data` text COLLATE utf8_unicode_ci NOT NULL, `cookie_start_time` datetime NOT NULL DEFAULT '1970-01-01 00:00:00', UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; Include DBSessionHandler…
Singleton Class saves resources There are several ways to implement singleton classes. In all methods, the class instance is created as \Namespace\ClassName::getInstance() Method 1: protected static $instances = array();// to solve the issue https://stackoverflow.com/questions/17632848/php-sub-class-static-inheritance-children-share-static-variables /** * @brief Singleton Constructor * * @return ClassInstance * * @details Caution: never call Class::getInstance() in another class's constructor, that…
URLs to note Composer Commands Ref, Packagist, Github, My Sample(osolutils/helpers) Submit to Packagist References https://www.youtube.com/watch?v=B2DFoO_CMwQ https://github.com/rakibtg/PHP-random-quotes-generator composer require rakibtg/php-random-quotes-generator After install , check the file vendor/composer/autoload_ps4.php to see the mapping Another reference https://blog.jgrossi.com/2013/creating-your-first-composer-packagist-package/ Steps Add PHP Project to Composer Packagist Ensure that the classes are stored in a folder named "src" To install without command…
Autoloading feature Autoloading helps us to load the future classes without any pain (see: dozen of include or require), Can be implemented with spl_autoload_register() click Use PSR-4 autoloading click Codes to implement the functionality is here. click For single prefix namespaces first block <?php /** * An example of a project-specific implementation. * * After…
Addendum So finally I cracked a way for it The algorithm is like this 1.just prior to session_start, a cookie cookie_start_time is set to current time. life time of this cookie will be same as that of session. Both uses the variable $this->cookieLifeTime to set life time 2. in session ‘_write’ we will set that…