Posts Categorized: php

Laravel Passport Oauth

With a basic CRUD Laravel app containing API routes I wanted to protect the API behind Oauth. So I followed the instructions on the Laravel documentation and a great video by Andre Madarang on Youtube. After following the steps of requiring passport in composer, migrating and adding the routes I was testing the oauth endpoints… Read more »

Laravel Quick Start

Quick reminder of steps to setup a Laravel project on Ubuntu/Linux Mint and similar. First install composer: sudo apt install composer Install PHP dependencies: sudo apt install php-cli-prompt php-common php-composer-semver php-composer-spdx-licenses php-fpm php-json-schema php-mysql php-symfony-console php-symfony-filesystem php-symfony-finder php-symfony-process php7.0-cli php7.0-common php7.0-fpm php7.0-gd php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml php7.0-zip php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-mysql   Use composer to create your Laravel project: composer create-project –prefer-dist laravel/laravel myprojectname Install composer.json packages: composer install Generate a key for your new project into the .env file: php artisan key:generate Amend the .env file with database details and anything else you want to customise. You may want to install mysql with sudo apt install mysql-server Auth Scaffolding… Read more »

Bleeding Edge PHP on CentOS 7

The PHP packages in the base / epel repositories are very conservative. To opt for something more current the REMI repo can be used. Install the remi-release package (info)  first: wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm rpm -ivh remi-release-7.rpm This will create the remi specific repo files in the /etc/yum.repo.d directory, specifically: remi-php70.repo remi.repo remi-safe.repo To install later PHP… Read more »

Deploying a Web Project from Gitlab

gitlab deploy hooks

I wanted to automatically deploy a web project when any updates are pushed to the gitlab repository. To do so I added a ‘Web Hook’. The Web Hook calls a URL in response to ‘push’ events. I created a PHP page to be called by the Web Hook: So in response to push events gitlab_hook.php… Read more »

PHP Built-In Web Server

LAMP Development just got a little easier with PHP version 5.4 and the in-built PHP web server. To test a PHP application we can now navigate to the directory on the filesytem: cd ~/websites/whatever.com/httpdocs Then run the PHP Web Server: php -S localhost:8000 In a web browser enter the location http://localhost:8000 to see your web… Read more »

Set Default Theme in phpMyAdmin on CentOS

phpmyadmin

I have installed phpMyAdmin on CentOS 6 via the EPEL repository using: yum install phpMyAdmin I was asked to set the default theme from the new jazzy one to the traditional one. To do so I edited the phpMyAdmin config file. On CentOS this was at /etc/phpMyAdmin/config.inc.php but on other installations it may be under… Read more »

Unlocking Active Directory Accounts using LDAP

I am using PHP with LDAP to manage some aspects of user accounts within Active Directory. One of the things I needed to do was to reset the accounts of users who had incorrectly entered their password too many times. Initially I thought that the ‘useraccountcontrol’ field was what I needed as this is used… Read more »

LDAPS Active Directory Issues with php-5.3.3-27.el6_5.2.x86_64

I upgraded a CentOS server today updating PHP from php-5.3.3-27.el6_5.x86_64 to php-5.3.3-27.el6_5.2.x86_64 This stopped a PHP web application I had written from being able to communicate with Active Directory over LDAPS. Normal LDAP appears to continue working fine but when I change my connections back to ldaps they stop working. To deal with the problem… Read more »

Retrieving folder.jpg thumbnails: PHP Script

When using XBMC we usually use the ‘Files’ menu. The folder icons under ‘Files’ do not show a preview thumbnail unless there is an image in the folder named ‘folder.jpg’. I could manually search for folder images for each movie but decided that would be time-consuming so I put together a wee PHP script –… Read more »

PHP Accessing an IMAP Mailbox

This week I started playing around with PHP and a honeypot mailbox I had created some time ago. The following PHP is what I have been using thus far – plenty more work to do:   $hostname = ‘{imap.domain.uk:143/notls}INBOX’; $username = ‘honeypot’; $password = ‘topsecret’; $inbox = imap_open($hostname,$username,$password) or die(‘Cannot connect to Mail server as… Read more »