Any #silex devs who want to add #indieauth sign-in or micropub to their applications? Take a look at github.com/taproot/authentication, I want to improve the documentation so indieauth can make more sense to new users.
Any #silex devs who want to add #indieauth sign-in or micropub to their applications? Take a look at github.com/taproot/authentication, I want to improve the documentation so indieauth can make more sense to new users.
@benatkin #protip: you can leave out the semicolon in that case with no ill effects #totallylikerubyexceptwithmorewords
@jack_way I know people who’ve had a good experience with Slim, I use silex.sensiolabs.org myself for almost everything now as it uses the Symfony components and is excellently designed.
@bracki pity it doesn’t work on Squeeze (why is that?), as far as I can see it doesn’t depend on a particular version of PHP, just anything greater than 5.3.9 — "php": ">=5.3.9"
, to be exact.
The elasticsearch PHP client is an excellent example of a well-written PHP service client. Very simple API with little surface area to memorize, uses PSR logging interface, easily configurable due to pimple-based design.
@seldaek apparently you can! packagist.org/packages/barnabywalters/gist-test#v0.1.0 Agreed it’s unlikely to be optimal for a lot of cases, but worth experimenting with reducing code sharing friction and boilerplate
Looks like gists can be used as minimal @packagist #composer package repos: https://gist.github.com/barnabywalters/8824041 https://packagist.org/packages/barnabywalters/gist-test — might be nice for tiny (e.g. single function) packages.
@igorwhiletrue thanks! I was aware of stackphp/run
, but wondered if there was an alternative which left the run method in place — Silex is such an exquisitely designed and concise abstraction it’s a pity to have to give that up and introduce extra packages, namespaces and functions (more surface area to learn and remember).
First #indieweb package derived from indiewebify.me code: indieweb/rel-me for consuming the rel-me microformat and verifying silo backlinks. Perfect for implementing an indieauth.com clone in #php…
@thatEmil that should work fine — one thing to bear in mind is that by default they both treat redirects differently. IIRC, cURL doesn’t follow redirects by default whereas file_get_contents
will.
@sandeepshetty sure! gist.github.com/barnabywalters/7863676 — included the basic functions plus the convenience class I use and a little demo. Very specific to chronological post storage/indexing, and very much in flux. I’d be interested to hear your thoughts about it.
New in this version of #taproot:
The local maximum has been overcome, for now. There is still much to do.
psysh.org is the #php REPL shell we have been waiting for. How to start an interactive shell with a given context:
<?php
require 'vendor/autoload.php';
$app = require 'src/app.php';
Psy\Shell::debug(['app' => $app]);
Supports readline, pcntl, registering custom commands, automatic semicolon insertion, clean+concise string representations of evaluated values. Amazing work Justin Hileman!
Had many basic software development lessons hammered in by personal experience over the last couple of years: hierarchy bad. side effects bad. many moving parts bad. undue complexity bad. inconsistency bad. SQL databases fragile. always be reducing.
It’s amazing just how seductive complex, unproductive tools can be. Successfully overcome+abandoned:
PHP remains productive and speedy (with composer, delightful dependency management), python nice with some irritations. jQuery useful when absolutely necessary, plain #js with small libraries loaded via requirejs handle most progressive enhancement concisely. node.js nice for some things, preferring go’s approach to async programming but still not much everyday need for it.
Avoiding middlemen: LESS, SASS, Coffeescript. Unnecessary for most of my work, and more moving parts is bad.
Now bothering me is the frameworky nonsense accumulating in #taproot. Need to cleanse.
Congratulations Aaron Parecki on implementing real-time #indieweb comments in #p3k using #webmention, websockets, redis, node.js and PHP. Very impressive indeed :)
How to emulate standard #php front-controller behaviour of routing static assets statically, otherwise calling index.php using the PHP 5.4 built-in server:
// file: index.php
// Route static assets from CLI server
if (PHP_SAPI === 'cli-server') {
if (file_exists(__DIR__ . $_SERVER['REQUEST_URI']) and !is_dir(__DIR__ . $_SERVER['REQUEST_URI'])) {
return false;
}
}
// do usual front-controller stuff
Achievement Unlocked: Functional PHP by passing an anonymous function as an argument to itself
I just faked having a task queue for #taproot #indieweb note posting tasks using Symfony HttpKernel::terminate()
and it was the easiest thing ever.
Instances or subclasses of HttpKernel
have a terminate($request, $response)
method which, if called in the front controller after $response->send();
triggers a kernel.terminate
event on the app’s event dispatcher. Listeners attached to this event carry out their work after the content has been sent to the client, making it the perfect place to put time-consuming things like POSSE and webmention sending.
Once you’ve created your new content and it’s ready to be sent to the client, create a new closure which carries out all the the time consuming stuff and attach it as a listener to your event dispatcher, like this:
$dispatcher->addListener('kernel.terminate', function() use ($note) {
$note = sendPosse($note);
sendWebmentions($note);
$note->save();
}
Then, provided you’re calling $kernel->terminate($req, $res);
in index.php, your callback will get executed after the response has been sent to the client.
If you’re not using HttpKernel and HttpFoundation, the exact same behaviour can of course be carried out in pure PHP — just let the client know you’ve finished sending content and execute code after that. Check out these resources to learn more about how to do this:
fastcgi_finish_request()
flush()
HttpFoundation\Request::send()
as a sample implementationFurther ideas: if the time consuming tasks alter the content which will be shown in any way, set a header or something to let the client side know that async stuff is happening. It could then re-fetch the content after a few seconds and update it.
Sure, this isn’t as elegant as a message queue. But as I showed, it’s super easy and portable, requiring the addition of three or four lines of code.