Skip to content

Instantly share code, notes, and snippets.

View settermjd's full-sized avatar

Matthew Setter settermjd

View GitHub Profile
@settermjd
settermjd / Want a Stellar Project? You Need to Document and Promote It.md
Last active August 29, 2015 14:22
Want a Stellar Project? You Need to Document and Promote It

Do you have an awesome WordPress plugin, Drupal module, Zend Framework module, or PHP library, one that you want people to use, to be truly successful, perhaps one people even rave about? Often, most of the effort expended on a project goes in to development, with documentation and promotion considered after-thoughts. But these two steps are essential to a project's success. In this session, I'll show you key ways to document and promote your project, so it's easier to find out about, to start using, to maintain, and to grow its reputation, using examples of real world successes.

@settermjd
settermjd / Powerful, Flexible, Maintainable SQL Generation - Without The Hassle.md
Last active August 29, 2015 14:22
Powerful, Flexible, Maintainable SQL Generation - Without The Hassle

PHP is almost synonymous with databases, and has been since the early versions. Yet creating SQL queries can still be a challenging task. What's the right tool to use? ORMs often feel like overkill. And creating queries by hand can be unmaintainable. In this session, I'll show you how to use the Zend\Db library to generate SQL queries; from simple selects, through to more complex unions, filtered deletions, and updates. You'll learn how to use the library to create flexible, secure, maintainable, and reusable queries quickly, and efficiently, saving you time and effort in the long term.

<?php
namespace DiExample;
class DummyDateCalculator
{
protected $date;
protected $secondDate;
public function __construct(\DateTime $date)
@settermjd
settermjd / DummyDateCalculator.php
Created July 24, 2015 10:37
Issue with using a factory to retrieve a service in PHP-DI
<?php
namespace DiExample;
class DummyDateCalculator
{
protected $date;
protected $secondDate;
public function __construct(\DateTime $date)
@settermjd
settermjd / database-schema.sql
Created September 22, 2015 07:36
Query across multiple databases in MySQL
DROP TABLE IF EXISTS `departments`;
CREATE TABLE `departments` (
`dept_no` char(4) NOT NULL,
`dept_name` varchar(40) NOT NULL,
PRIMARY KEY (`dept_no`),
UNIQUE KEY `dept_name` (`dept_name`),
KEY `idx_deptno` (`dept_no`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `dept_emp`;
@settermjd
settermjd / app -> config -> sculpin_kernel.ml
Last active October 5, 2015 11:48
Creating a custom type in Sculpin
sculpin_content_types:
posts:
permalink: pretty
portfolios:
enabled: true
@settermjd
settermjd / cache-config.php
Created October 30, 2015 11:31
Cache configuration showing how to configure Zend\Cache to work with Redis.
<?php
if (extension_loaded('redis')) {
return [
'caches' => [
'Cache\Transient' => [
'adapter' => 'redis',
'ttl' => 60,
'plugins' => [
@settermjd
settermjd / dependencies.global.php
Created October 30, 2015 11:32
Zend-Expressive Dependencies configuration which adds Zend\Db and Zend\Cache support.
<?php
return [
'dependencies' => [
'invokables' => [
App\Action\PingAction::class => App\Action\PingAction::class,
],
'factories' => [
App\Action\HomePageAction::class => App\Action\HomePageFactory::class,
Zend\Expressive\Application::class => Zend\Expressive\Container\ApplicationFactory::class,
@settermjd
settermjd / gist:5802655
Created June 18, 2013 04:19
Creating a nested SQL query with \Zend\Db\Sql
$select->where(array("ItemID" => (int)$itemId));
$select->where->and->nest
->like('FirstName', $inputFilter->getValue("searchCriteria") . "%")
->or->like('FirstName', "%" . $inputFilter->getValue("searchCriteria"))
->or->like('LastName', $inputFilter->getValue("searchCriteria") . "%")
->or->like('LastName', "%" . $inputFilter->getValue("searchCriteria")
);
@settermjd
settermjd / gist:6778757
Last active December 24, 2015 09:39
Handle Umlauts and other characters in DOMPDF
$pdf = new DOMPDF();
$pdf->load_html(utf8_decode($customtext));