Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
May 12, 2014
Chris
PHP
Comments Off on “Belt” adds very clever everyday functions to PHP, comes with JavaScript naming styles and eventually solves the needle/haystack problem

“Belt” adds very clever everyday functions to PHP, comes with JavaScript naming styles and eventually solves the needle/haystack problem

PreviousNext
php

This little projects is basically super-simple, but somehow really really clever and definitly a time-saver: Belt is a typical Composer-loaded dependency that adds a lot of useful functions “to PHP”. Some of these functions are more or less duplicates of already existing one in native PHP, buuuut they solve the common unsteady needle / haystack vs. haystack /needle parameter-order problem in PHP (and narrow to the beautiful Java / JavaScript function/method naming convention). A very interesting project, hopefully with a great future! Let’s see some examples (some examples show callable code, some show method definitions):

// returns the max value of an array
Belt::max([1, 2, 3]); // => 3

// checks if arguments are equal
Belt::isEqual("yeah", "nope"); // => false

// flattens a multi-dimensional array
Belt::flatten([1, [2, [3]]]) // => [1, 2, 3]

// create an array containing a range of elements, optional with steppings
Belt::range(1, 10, 2); // => 1, 3, 5, 7, 9

// returns an array containing the unique items in both arrays
union($array1, $array2)

// execute $closure only once and ignore future calls [interesting stuff!]
once(Closure $closure)

// only execute $closure after the exact $number of failed tries
after($number, Closure $closure)

// escape all HTML entities in a string
escape($string)

// invoke a $closure $number of times
times($number, Closure $closure)

// iterate through $collection using $iterator
each(array $collection, Closure $iterator)

// convert $value to an array
toArray($value)

// group values in $collection by $iterator's return value
groupBy(array $collection, Closure $iterator)

// determine whether the given object has a key
has($object, $key)

// copy all properties from $source to $destination
extend($source, $destination)

// fill in any missing values using $defaults
defaults($object, $defaults)

// determine whether the given value is a float or an integer
isNumber($value)

Link: Belt on GitHub

belthaystackmethodnamesnaming conventionsneedlePHP
Share this

Going node.js at Netflix (Slides by Micah R of Netflix)

It’s awesome how node.js takes over the absolute AAA-level corporate world. Note that node.js is still an early alpha product

composer

[Link] How to require versions of PHP, HHVM / HipHop, GD, curl, openssl etc. with Composer

Jeremy Kendall has just published a short and excellent overview on how to require versions of PHP (and explicit 64-bit

dev coding cards deck

Nice gifts for devs: Nerdy playing-cards decks

Wonderful idea: Playing cards decks for developers. No, not scrum-cards, more the classic stuff. Code:deck $10 plus $5 for shipping

php

Test out PHP 5.6alpha1 on Windows 7 / 8 with two clicks

The popular Apache-MySQLP-PHP stack EasyPHP has become very professional, maintained and especially modularized in the last 2 years, and when

Awesome next-gen PS4 graphics in “The Order: 1886”

We are entering a very interesting time: The differences between cinematic movies and video games are getting lesser and lesser.

[Link] Redesigning SoundCloud by Evan Simoni

Again, an interesting approach / proof-of-concept on a redesign of a major website. Evan Simoni has overthought SoundCloud’s UI and

[Link] Interesting: Designing a Nuclear Waste Warning Symbol That Will Still Make Sense in 10,000 Years

Interesting article for everybody with a faible for UI/UX: Slate – Designing a Nuclear Waste Warning Symbol That Will Still

october cms

October CMS, built on top of Laravel, is beautiful, clever and on the way to be the new #1 CMS

Do you remember when you tried to edit one line of code inside TYPO3 or Contao ? And the extreme

php

appserver.io – A New Way of Magento Enterprise Infrastructure (26min video talk)

Interesting stuff for all Magento people (unfortunatly the audio level is very low):

Hacking ATMs – A conference talk about the current security state of Windows XP driven cash machines

A few days ago the 30th edition of Germany’s Chaos Communication Congress took place, a high-profile event for IT-security and

1/4

Categories

Search

html6
Is this the first HTML6 specification?
How major web companies (and banks) handle passwords quite wrong
offf-2014
Europeans: Get ready for OFFF conference / festival in Barcelona, May 2014
php
How the PHP session garbage collector really works
bash-command-line-tutorial
Best introduction to unix command line / bash ever (by André Augusto Costa Santos)
Interesting stats on SONY’s hacked passwords
Adobe releases Firebug-like developer tools to edit and extract PSDs
composer
How to install Composer on Windows 7 / 8 or Ubuntu
composer
[Link] How to require versions of PHP, HHVM / HipHop, GD, curl, openssl etc. with Composer
Frontend Ops Conf 2014 – Rebooting Flickr On A Node.js Stack, One Page At A Time (from PHP) by Bertrand Fan
phpstorm 7.0 php
PHPStorm 7 has been released!
How Instagram.com works
october cms
[Link] How To Install October CMS on a VPS running Ubuntu 14.04
nginx php 5.5
[Link] Set up Nginx with PHP 5.5 easily
logo-internet-explorer
How to professionally test on old Internet Explorer versions

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy