Setting UP Google Login for Website

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…

Set MySQL DB Session Handler

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…

Creating PHP Singleton Classes

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…

Creating first composer package to packagist

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…

Software Testing Plan

Ref: https://www.youtube.com/watch?v=NiDe8lj-wGs 15 Attributes in test plan Objectiive : Aim of test plan Scope : Features going to be tested and not tested Testing Methodology : Eg: For Web apps Ref1 , Ref2 Unit Testing : Specify and test one point of the contract of single method of a class. Integration Testing : There is…

Software Licenses

Primarily 2 Types Free and Open Source a.k.a FOSS(Free with or without Conditions) Proprietary FOSS can be further classified to 4 based on level of restrictions Public Domain(no license) : No restrictions (but it is the responsibility of the one who uses/modifies/redistributes software available in public domain to ensure that no license is attached) Lesser…

Autoloading in PHP

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…

Creating a basic MVC in PHP

<?php // Define Paths // create folders // create files // load contents in files // device algorithm to create new feature/component $projectFolders = array( array( "name" => "public", "id" => "f1", "parent" => "" ), array( "name" => "private", "id" => "f2", "parent" => "" ), array( "name" => "core", "id" => "f3", "parent"…

PHPWord : Ordered list with TemplateProcessor

There are 3 ways to do it Each methods has its own Pros and Cons Crass way , Subclassing container class and using templateProcessor->setComplexBlock templateProcessor->setComplexBlock will give Error, Uncaught Error: Class ‘PhpOffice\PhpWord\Writer\Word2007\Element\Section’ not found. That is why container subclass is used namespace PhpOffice\PhpWord\Writer\Word2007\Element; class Section extends Container{} and then $phpWord = new \PhpOffice\PhpWord\PhpWord();//$this->templateProcessor->makeTable();//new \PhpOffice\PhpWord\PhpWord(); $section…