Generating Subresource Integrity Checksums with PHP

Generating Subresource Integrity Checksums with PHP

<?php
function checkSum($algo, $input) {
$hash = hash($algo, $input, true);
$hash_base64 = base64_encode($hash);
return $algo.'-$hash_base64';
}
?>

Example <script src="https://code.rifix.net/jquery/3.1.0/jquery.min.js" integrity="<?php echo checkSum('sha384','https://code.rifix.net/jquery/3.1.0/jquery.min.js'); ?>" crossorigin="anonymous"></script>

PHP Standards Recommendations – PSR

php-figAccording to the PSR Workflow Bylaw each PSR has a status as it is being worked on. Once a proposal has passed the Entrance Vote it will be listed here as “Draft”. Unless a PSR is marked as “Accepted” it is subject to change. Draft can change drastically, but Review will only have minor changes.

As also described in the PSR Workflow Bylaw. The Editor, or editors, of a proposal are the essentially the lead contributors and writers of the PSRs and they are supported by two voting members. Those voting members are the Coordinator who is responsible for managing the review stage and votes; and a second sponsor.

Accepted PSRs:

GA:PI() – Google Analytics PHP Interface and OAuth2

Go to Google Console

Enable Google Analytics API

Create new project

google-console

Go to APIs & auth > Credentials
Click on Create new Client ID, and select Service account and P12 key. Then click on Create Client ID to download it.

ga-admin

Go to Google Analytics Admin and give permissions for read & analyze to the new email that looks something like 381198546241-kwuf1jrlpqbpq1523sx1k0h37tidybhe@developer.gserviceaccount.com

Download gapi-google-analytics-php-interface

And finally some php code:


define('ga_profile_id','YOUR_PROFILE_ID');
$ga = new gapi("381198546241-kwuf1jrlpqbpq1523sx1k0h37tidybhe@developer.gserviceaccount.com","PATH_TO_YOUR_P12_KEY.p12");
$ga->requestReportData(ga_profile_id, $dimensions, $metrics, $sort_metric, $filter, $start_date, $end_date, $start_index=1, $maxResults=30);

This are the basic steps

Install Zend Framework 2 Via Composer

ZF2 Skeleton Application

Starting with Zend Framework 2, you may now install Zend Framework or any of its individual components and their dependencies, using the dependency management tool Composer. Packages are provided by our dedicated packages repository at packages.zendframework.com.

To use our packages with Composer, add the following to your composer.json to enable our repository:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.zendframework.com/"
    }
],

You can then add any of our packages to your require list. For example:

"require": {
    "zendframework/zend-config": "2.0.*",
    "zendframework/zend-http": "2.0.*"
},

Run the install command to resolve and download the dependencies:

php composer.phar install

Installing Yii PHP Framework

My Yii Application

You can install Yii in two ways, using Composer or by downloading an archive file. The former is the preferred way, as it allows you to install new extensions or update Yii by simply running a single command.

Note: Unlike with Yii 1, standard installations of Yii 2 result in both, the framework and an application skeleton being downloaded and installed.

 

Read more

Laravel Quickstart

Laravel PHP Framework

Install Laravel

Via Laravel Installer

First, download the Laravel installer using Composer.

composer global require "laravel/installer=~1.1"

Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable is found when you run the laravel command in your terminal.

Once installed, the simple laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog would create a directory named blog containing a fresh Laravel installation with all dependencies installed. This method of installation is much faster than installing via Composer.

Via Composer Create-Project

You may also install Laravel by issuing the Composer create-project command in your terminal:

composer create-project laravel/laravel --prefer-dist

Server Requirements

The Laravel framework has a few system requirements:

  • PHP >= 5.4
  • MCrypt PHP Extension

As of PHP 5.5, some OS distributions may require you to manually install the PHP JSON extension. When using Ubuntu, this can be done via apt-get install php5-json.

Yii PHP Framework

yii framework

Yii is a high-performance component-based PHP framework best for Web 2.0 development. Yii is an open source, object-oriented, component-based MVC PHP web application framework. Yii is pronounced as “Yee” or [ji:] and it’s an acronym for “Yes It Is!”