Software Developer. Computer Geek. INTJ.

Tag PHP

Laravel Breadcrumbs Fork

github.com/diglactic

Sheng Slogar of Diglactic has volunteered to take forward the Laravel Breadcrumbs project.

Using Blade Outside Laravel

Using Jens Segers’ Blade package to render Blade templates in a standalone PHP application.

Laravel Breadcrumbs Redux

I’ve decided to start working on Laravel Breadcrumbs again…

Laravel’s Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn’t cover all of the available functionality, so I decided to experiment with it and document it for myself.

PHP CLI script that can also be run in a web browser

I had a command line (CLI) script written in PHP that I wanted to be able to run via the web, to save having to open a terminal and SSH connection each time.

Display a list of a user’s Gists in WordPress

This code creates a shortcode, [gists], which displays a list of all Gists by a user, grouped into categories then listed alphabetically.

Laravel Boris

git.djm.me

Adds an artisan boris command to Laravel 4.0 that runs the Boris REPL in the Laravel environment.

Laravel Breadcrumbs

git.djm.me

A simple Laravel-style way to create breadcrumbs.

Laravel Aliases

git.djm.me

Adds an artisan aliases command to Laravel that lists registered aliases and the classes they map to, including resolving facades.

Installing PHP 5.4 on Debian 6 (Squeeze)

Debian 7 (Wheezy) is due to come out soon, but I didn’t want to wait to upgrade to PHP 5.4, nor to install the release candidate. I tried using the Wheezy repository, but got dependency errors. Fortunately Dotdeb provides packages for…

Installing PHP 5.2 FastCGI on a cPanel server (alongside PHP 5.3+)

This is based on my instructions for Debian and a bit from this forum post. It requires root access and you must be comfortable using the command line.

Write to standard output/error streams in PHP CLI

How to write to STDOUT and STDERR in PHP.

Recursively copy a directory, including symlink support, in PHP

function copy_dir($src, $dst)

Recursively delete a directory, including symlink support, in PHP

function delete_dir($dir)

Get HTTP redirect destination for a URL in PHP

Makes a HTTP request and read the Location header(s) to determine the redirect destination.

Resize an image on the fly with PHP and cache it (like Drupal’s ImageCache)

This script takes an image and resizes it to the given dimensions, then saves that version on the filesystem so Apache can serve it directly in the future.

Zip a dynamically generated file in PHP

// Generate the contents of the file somehow $content = ‘…’; // Zip the file $zipFile = tempnam(sys_get_temp_dir(), ‘zipfile’); $zip = new ZipArchive; $zip->open($zipFile, ZipArchive::OVERWRITE); $zip->addFromString(‘sample.txt’, $content); $zip->close(); // Do something with the file (e.g. attach it to an email)…

Installing PHP FastCGI with suEXEC on Debian

Most of the time I’m happy with mod_php. It’s certainly the most efficient way to run PHP. But there is one major downside – all scripts are run as the Apache user (www-data). We can get around this by using…

HTML to PDF conversion in PHP using wkhtmltopdf (and Smarty)

Recently I was asked to generate PDF invoices for an online shop. I looked at various PHP PDF generators, but wasn’t particularly impressed with any of them. Then I found (via Stack Overflow) a command-line HTML-to-PDF convertor called wkhtmltopdf, which…

Connecting PHP to Microsoft SQL Server on Linux

Here is how to get PHP 5.2 on Linux (specifically Debian/Ubuntu) talking to a Microsoft SQL Server database

Installing PHP 5.2 FastCGI on Debian 6 (Squeeze)

Debian Squeeze comes with PHP 5.3. This is good, because PHP 5.2 is no longer maintained, but causes problems for old applications that can’t support it (e.g. ViArt 3, because it uses Zend Encoder). Rather than permanently downgrade PHP for the whole server,…

Get the domain name from a URL for display purposes in PHP

This is a very simple function to convert a user-supplied URL to just the domain name.

djmFiles

git.djm.me

Functions for handling files & file uploads.

djmWebDirConfig

git.djm.me

Load per-directory PHP config files (similar to Apache .htaccess files but containing PHP code).

djmErrors

git.djm.me

Setup error handling to log or display depending on the DEBUG environment variable.

djmSecurityCheck

git.djm.me

Check settings for register_globals & magic_quotes_gpc.

djmCountries

git.djm.me

Country list and associated functions & Smarty plugins.

djmCSV

git.djm.me

Converts an array of data to a CSV file.

djmPassword

git.djm.me

Store passwords as SHA-256 hashes with a random salt.

djmIndexU

git.djm.me

Functions to help with modifying Nicecoder IndexU.

djmFlashMessage

git.djm.me

Stores flash messages in the user session and clears automatically when displayed.

djmLinkify

git.djm.me

PHP functions to make URLs clickable in plain text input.

djmNonce

git.djm.me

Generate & check nonces to protect against CSRF attacks.

djmSingletons

git.djm.me

Base class for holding singleton objects, automatically instantiating them when required.

djmUtil

git.djm.me

General utility functions and Smarty plugins.

djmDB

git.djm.me

Custom subclasses of Zend_Db (database abstraction layer).

djmForm

git.djm.me

Helper functions & Smarty plugins for creating web forms.

djmHead

git.djm.me

Generate the <head> code (title, meta description, etc.) in the application controller/views then display it in the layout.

PHP Mate

git.djm.me

A general-purpose library for PHP websites.

© 2021 Dave James Miller — Powered by WordPress

Theme by Anders NorenUp ↑