fabic974 random (binary) wanderings in the philament empires…

PHP: personal notes

Packages and stuff of general interest

cocur/slugify vs Laravel’s str_slug()

Composer, packages

About PDFs

Laravel

Symfony

Other

  • bshaffer.github.io : OAuth 2.0 server php
  • Asana on “what is oauth”
  • About proxies: http://ocramius.github.io/presentations/proxy-pattern-in-php/

      require_once 'vendor/autoload.php';
      use ProxyManager\Factory\LazyLoadingValueHolderFactory;
    
      $factory = new LazyLoadingValueHolderFactory();
    
      $proxy = $factory->createProxy(
          'My\Slow\Foo',
          function (& $wrappedObject, $proxy) {
              $wrappedObject = new My\Slow\Object();
    
              $proxy->setProxyInitializer(null);
          }
      );
    
      $proxy->doFoo();
    

    Or you can just resort to __call() magic :

      class test {
          function __construct(){}
    
          private function test1(){
              echo "In test1", PHP_EOL;
          }
    
          public function __call($method,$arguments)
          {
              if(method_exists($this, $method)) {
                  $this->test1();
                  return call_user_func_array(array($this,$method),$arguments);
              }
          }
      }
    
  • Generate random hash string SO:

      echo bin2hex(random_bytes($length));
      echo bin2hex(openssl_random_pseudo_bytes(16));
      echo bin2hex(mcrypt_create_iv(128, MCRYPT_DEV_RANDOM));
      echo md5(uniqid(mt_rand(), true)); // not considered safe.
      echo str_shuffle('ASGDHFfdgfdre5475433fd');
    

Misc.

EOF