-
What frameworks or libraries do you generally pull in when starting a fresh PHP project? Why do you use them?
My only must have is either phpspec or PHPUnit. I prefer phpspec, but it makes rather opinionated assumptions about project structure, so PHPUnit is much easier to set up on older projects.
Beyond that, I've had good luck with both Silex and Twig. They're both simple, focused libraries to provide the Controller and View components, respecitvely, of a MVC framework.
To be honest, though, most of my fresh projects aren't in PHP. I prefer either Ruby or NodeJS when given the choice. Most of my experience with PHP has been picking up existing projects and using whatever framework and tools already exist on them.
-
If I told you that we needed to use a third party API to get some arbitrary data, would you prefer XML or JSON? Why?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Database connection info | |
user=ssh_username | |
password=ssh_password | |
host=ssh_host | |
db=ssh_database | |
# Filename settings | |
path=~/dbbackups/ | |
name=dbbackup`date +%y%m%d`.sql.bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
# Blue Acorn staging site setup script | |
# v0.1 | |
# by Ben Cates | |
### | |
domain='local' | |
server='mamp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURRENT_DIR=/home/ | |
DAEMON=$CURRENT_DIR/bin/thin | |
CONFIG=$CURRENT_DIR/config/thin.yml | |
SCRIPT_NAME=/etc/init.d/thin | |
# Exit if the package is not installed | |
[ -x "$DAEMON" ] || exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TTYBackend < SSHKit::Backend::Printer | |
def execute(*args) | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
command(*args).tap do |cmd| | |
output << cmd | |
cmd.started = Time.now | |
system %Q{ssh -l #{@host.user} #{@host.hostname} -t "#{cmd.to_command}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PrettyUrls | |
class Generator < Jekyll::Generator | |
def generate(site) | |
site.pages.each do |page| | |
if page.name.split('/').last !~ /^index.\w+$/ | |
page.data['permalink'] ||= page.name.gsub(/\.\w+$/, '/index.html') | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>SVG Test</title> | |
</head> | |
<body> | |
<svg id="s" version="1.1" | |
width="300" height="300" | |
xmlns="http://www.w3.org/2000/svg"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use Vim extensions; must be first thing in file | |
set nocompatible | |
" Use a POSIX compliant shell | |
set shell=/bin/bash | |
" BEGIN Vundle setup | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Applicant | |
def recent_rejection_reasons | |
rejection_reasons.where("rejection_reasons.created_at > '#{longest_days_ago}'") | |
end | |
end | |
class RejectionReason | |
def recently_rejected? | |
recency_cutoff = RejectionReason::REJECTION_REASON_CODES[reason_code][:days_blocked].days.ago | |
created_at > recency_cutoff |
OlderNewer