Skip to content

Instantly share code, notes, and snippets.

@samvasko
Created May 9, 2013 14:12
Show Gist options
  • Save samvasko/5547662 to your computer and use it in GitHub Desktop.
Save samvasko/5547662 to your computer and use it in GitHub Desktop.
Steps for parsing snippets form laravel source

Parsing v2

Grep names of Facades from config\app.php

grep -r 'Illuminate\\Support\\Facades' app.php | cut -d \' -f2

Those Are

App Artisan Auth Blade Cache Config Cookie Crypt DB Event File Form Hash HTML Input Lang Log Mail Paginator Password Queue Redirect Redis Request Response Route Schema Session URL Validator View

Now resolve their real name from facade using this ruby script

acessors.rb

include 'awesome_print'

f = [ names ];
out = Hash.new
for of in f
    fl = File.read(of+'.php')
    for line in fl.lines
        if line.match(/getFacadeAccessor/) != nil
            mt = line.match(/\'(\w+)\'/)
            if mt == nil
                # puts 'wired: ' + line
            else
                # puts of + ' ' + mt[1]
                out[of] = mt[1]
            end
        end
    end
end

ap out

Now we have a list of Aliases with their acessors Using this script in __callStatic in Facade.php file

Facade.php

$mts = [ output from previous function ]
foreach ($mts as $mt => $tores) {
    $inst = static::resolveFacadeInstance($tores);
    $reflector = new \ReflectionClass($inst);
    echo ucfirst($mt).' '.$reflector->getFileName().'<br>';
}

Now we have list of Aliases with filenames they refer to, yay !

files.txt

App C:\Users\Samuel\Dropbox\webdesign\www\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php
...

Most of the work went into this script, it greps functions from the those files and transforms them into snippets

snippet_parsing.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment