code
stringlengths
1
2.01M
language
stringclasses
1 value
<?php class Sample_Resource_Hello extends Asar_Resource { function GET() { return "Hello there!"; } }
PHP
<?php class Sample_Application extends Asar_Application { }
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?php echo isset($title) ? $title : 'Sample App'?></title> </head> <body> <?php echo $content ?> </...
PHP
<h1><?= $h1 ?></h1> <p>Blalalkajdf;jasd;</p>
PHP
<?php /* set_include_path( realpath(dirname(__FILE__) . '/../../../lib/core') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../apps') . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../lib/vendor') . PATH_SEPARATOR . get_include_path() );*/ require_once realpath(dirname(__FILE__) . '/../../../lib/core/Asa...
PHP
<?php class RemoveSvnEntries implements \Asar\Utility\Cli\CliInterface { private $cwd; private $controller = null; function __construct() { $this->cwd = getcwd(); } function setController(\Asar\Utility\Cli $controller) { $this->controller = $controller; } function getTaskNamespace() { ...
PHP
<?php // INTERNAL HEADERS 'Asar-Internal' => array( 'original_path' => '/some/where', 'isForwarded' => true, ); // CONFIG DEFAULTS: array( 'default_classes' => array( 'application' => 'Asar_ApplicationBasic', 'config' => 'Asar_Config_Default' ), 'templates' => array( 'engines' => array...
PHP
<?php $foo = array('bar' => array('baz' => 'yo')); var_dump(isset($foo['bar']['baz']));
PHP
<?php namespace Asar\Tests; class TempFilesManager { private $temp_dir; function __construct($dir) { if (!file_exists($dir)) { throw new TempFilesManager\Exception( "The directory specified ($dir) as temporary directory " . "does not exist." ); } $this->temp_dir = $di...
PHP
<?php namespace Asar\Tests; class TestServerManager { private static $can_connect; private $test_data_path; function __construct($test_data_path) { $this->test_data_path = $test_data_path; } private function constructPath() { $args = func_get_args(); return implode(DIRECTORY_SEPARATOR, ...
PHP
<?php namespace Asar\Tests\Functional\LoggingExample\LoggingExample\Resource; class Index extends \Asar\Resource { function GET() { /** * @todo this is overly complicated. The registration code should be * refactored and rethought. */ $logger = \Asar\Logger\Registry::getLogger($this); ...
PHP
<?php namespace Asar\Tests\Functional\LoggingExample\LoggingExample; class Config extends \Asar\Config { protected $config = array( 'use_templates' => false, ); function init() { $this->config['log_file'] = \Asar::getInstance() ->getFrameworkTestsDataTempPath() . DIRECTORY_SEPARATOR . 'examp...
PHP
<?php namespace Asar\Tests\Functional\DebuggingExample\DebuggingExample\Resource; class Index extends \Asar\Resource { function GET() { return array( 'h1' => 'Debugging Tests' ); } }
PHP
<?php namespace Asar\Tests\Functional\DebuggingExample\DebuggingExample; class Config extends \Asar\Config { protected $config = array( 'mode' => 'development', ); }
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?= isset($title) ? $title : 'Debugging Functional Tests'?></title> </head> <body> <?= $content ?> ...
PHP
<h1 id="the_head"><?=$h1?></h1>
PHP
<?php namespace Asar\Tests\Functional\StatusCodesExample\StatusCodesExample\Resource; class Page extends \Asar\Resource { function GET() { return array('heading' => "This is a test."); } }
PHP
<?php namespace Asar\Tests\Functional\StatusCodesExample\StatusCodesExample\Resource; class A500 extends \Asar\Resource { public function GET() { throw new \Exception('Something is wrong.'); } }
PHP
<?php namespace Asar\Tests\Functional\StatusCodesExample\StatusCodesExample\Resource; class Index extends \Asar\Resource { public function GET() { $this->setConfig('use_templates', false); return "This is a test."; } }
PHP
<?php namespace Asar\Tests\Functional\StatusCodesExample\StatusCodesExample\Resource; /** * @note due to classname limitations in PHP, we cant have classnames that * start with a number. */ class A405 extends \Asar\Resource { function GET() { return "Get request"; } function POST() { return "Po...
PHP
<?php namespace Asar\Tests\Functional\StatusCodesExample\StatusCodesExample; class Application extends \Asar\Application { protected function setUp() { $this->setMap('/', 'Index'); $this->setMap('/page', 'Page'); $this->setMap('/a500', 'A500'); } }
PHP
<html> <head> <title>A Page</title> </head> <body> <h1><?=$heading?> </body> </html>
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource\Blog; class RtYear extends \Asar\Resource { function GET() { return $this->request->getPath() . ' GET.'; } function qualify($path) { return preg_match('/^[1-9][0-9]{3}$/' , $path['year']); } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource\Blog\RtYear\RtMonth; class RtTitle extends \Asar\Resource { function GET() { $path = $this->getPathComponents(); return $path['title']; } function qualify($path) { return preg_match('/^[1-9][0-9]{3}$/' ...
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource\Blog\RtYear; class RtMonth extends \Asar\Resource { function GET() { return $this->request->getPath() . ' GET.'; } function qualify($path) { return preg_match('/^[1-9][0-9]{3}$/' , $path['year']) && p...
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource\AParent\Child; class GrandChild extends \Asar\Resource { function GET() { return $this->getPath() . ' GET.'; } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource\AParent; class Child extends \Asar\Resource { function GET() { return '/a-parent/child GET.'; } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource; class Index extends \Asar\Resource { function GET() { return '/ GET.'; } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource; class ForwardToChild extends \Asar\Resource { function GET() { $this->forwardTo('AParent\Child'); } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource; class Blog extends \Asar\Resource { function GET() { return '/blog GET.'; } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource; class AParent extends \Asar\Resource { function GET() { return '/a-parent GET.'; } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing\Resource; class RedirectOne extends \Asar\Resource { function GET() { $this->redirectTo('AParent\Child\GrandChild'); } }
PHP
<?php namespace Asar\Tests\Functional\ResourceTraversing\ResourceTraversing; class Config extends \Asar\Config { protected $config = array( 'use_templates' => false, 'site_domain' => 'asar-test.local', 'site_protocol' => 'http', ); }
PHP
<?php namespace Asar\Tests\Functional\DirectResourceMapping\Example1\Resource; class What extends \Asar\Resource { function setUp() { $this->config['use_templates'] = false; } function GET() { return "What's your name?"; } function POST() { $name = $_POST['name']; return "Hello $name!"...
PHP
<?php namespace Asar\Tests\Functional\DirectResourceMapping\Example1\Resource; class Index extends \Asar\Resource { function setUp() { $this->config['use_templates'] = false; } function GET() { return 'Hello World!'; } }
PHP
<?php namespace Asar\Tests\Functional\DirectResourceMapping\Example1; /** * Test Example1 Application Class * * This is the Application definition for the application application * named 'Example1'. This test application is used only for integration * testing. */ class Config extends \Asar\Config { protecte...
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class Xml extends \Asar\Resource { public function GET() { return array('foo' => 'This is from Xml.php'); } }
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class AltTemplate extends \Asar\Resource { function setUp() { // TODO: How do we set a different template engine? //$this->setConfig('template_engines.phaml', 'Asar_Template_Engines_Haml'); //var_dump($this->config_bag)...
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class CssAndJs extends \Asar\Resource { public function GET() { } }
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class Index extends \Asar\Resource { public function GET() { return array('p' => 'This is the paragraph. Easy, no?'); } public function POST() { return array( 'h2' => 'This is the subheading for the POST templa...
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class ContentNegotiation extends \Asar\Resource { public function GET() { return array('foo' => 'This is from ContentNegotiation.php'); } }
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class Alternative extends \Asar\Resource { public function GET() { return array('p' => 'This is an alternative template setup.'); } }
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class SetLayout extends \Asar\Resource { public function GET() { return array( 'p' => 'This is the paragraph from SetLayout.php' ); } }
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample\Resource; class Nolayout extends \Asar\Resource { public function GET() { return array( 'h1' => 'This is the main heading.', 'p' => 'This is the paragraph. Easy, no?' ); } }
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample; class Application extends \Asar\Application { protected function setUp() { $this->setMap('/', 'Index'); $this->setMap('/nolayout', 'Nolayout'); $this->setMap('/set-layout', 'SetLayout'); $this->setMap('/alternative', 'Alternat...
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample; class Config extends \Asar\Config { protected $config = array( 'template_engines' => array( 'atpl' => 'Asar\Tests\Functional\TemplatesExample\TemplatesExample\AtplTemplateEngine' ) ); }
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?php echo isset($title) ? $title : 'Template Functional Tests'?></title> </head> <body> <?php echo...
PHP
<h1>In ContentNegotiation/GET.html.php.</h1> <p><?= $foo ?></p>
PHP
===================================================== In ContentNegotiation/GET.txt.php. ===================================================== <?= $foo ?>
PHP
<h1>This is the main heading found in Alternative.GET.html.php.</h1> <p><?php echo $p ?></p>
PHP
<h1>This is the main heading found in Index/GET.html.php.</h1> <p><?= $p ?></p>
PHP
===================================================== This is the main heading found in Index/GET.txt.php. ===================================================== <?= $p ?>
PHP
<h1>This is the main heading found in Index/POST.html.php.</h1> <h2><?= $h2 ?></h2> <div> <p><?= $p ?></p> </div>
PHP
<bar> <foo><?= $foo ?></foo> </bar>
PHP
<?php if (isset($_helpers) && $assets = $_helpers['assets']) { $assets->includeJs('js/foo.js', 'js/bar.js'); $assets->includeJs('js/bar.js'); $assets->includeCss('css/foo.css'); } ?> <h1>Javascript and CSS Include Example</h1>
PHP
<?php namespace Asar\Tests\Functional\TemplatesExample\TemplatesExample; use \Asar\Template\TemplateInterface; /** * TemplatesExample_AtplTemplateEngine * * This is a super simple template engine that uses a str_replace. This * is only used for demonstrating how an alternative template engine can * be used in y...
PHP
<?php namespace Asar\Tests\Functional\RepresentationExample\RepresentationExample\Resource; class Index extends \Asar\Resource { function GET() { return array( 'h1' => 'Hello World!', 'p' => 'This is the paragraph. Easy, no?' ); } }
PHP
<?php namespace Asar\Tests\Functional\RepresentationExample\RepresentationExample; class Application extends \Asar\Application { protected function setUp() { } }
PHP
<representation> <h1><?php echo $h1 ?></h1> <p><?php echo $p ?></p> </representation>
PHP
<?php namespace Asar\Tests\Functional\RepresentationExample\RepresentationExample\Representation; class Index extends \Asar\Representation { function getHtml($data) { return '<html> <head> <title>Representation Example Index</title> </head> <body> <h1>'. $da...
PHP
<?php namespace Asar\Tests; class Exception extends \Exception {}
PHP
<?php namespace Asar\Tests; /** * A helper class to wrap common test setups in one class for easier testing. */ abstract class TestCase extends \PHPUnit_Framework_TestCase { protected function quickMock($class, array $methods = array()) { return $this->getMock($class, $methods, array(), '', false); } ...
PHP
<?php namespace Asar\Tests\TempFilesManager; use \Asar\Tests\Exception as TestsException; class Exception extends TestsException {}
PHP
<?php ini_set('error_reporting', E_ALL | E_STRICT); $lib_path = realpath(__DIR__ . '/../lib/') . '/'; require_once $lib_path . 'asar/Asar/ClassLoader.php'; /** * @todo Use a different library in the future */ require_once __DIR__ . '/simple_html_dom.php'; $classLoader = new \Asar\ClassLoader('Asar\Tests', __DIR__)...
PHP
<?php /******************************************************************************* Version: 1.11 ($Rev: 175 $) Website: http://sourceforge.net/projects/simplehtmldom/ Author: S.C. Chen <me578022@gmail.com> Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/) Contributions by: Yousuke ...
PHP
<?php // This is just dummy data. // Please see tests/unit/core/Asar/Utility/Cli/TaskFileLoaderTest.php return 'foobar';
PHP
<?php // See tests/unit/core/Asar/Utility/ClassFilePeekTest.php class Asar_ClassFilePeekTest_Foo { } class Asar_ClassFilePeekTest_Bar extends Asar_ClassFilePeekTest_Foo { }
PHP
<?php var_dump($_POST); var_dump($_SERVER); var_dump($_ENV); var_dump( file_get_contents('php://input') );
PHP
<?php require_once 'Asar/Toolset.php'; /** * The Asar class. Useful for getting information about the framework * and its directories. * */ class Asar { private static $paths = array(), $instance; private $toolset; /** * @param string $key path key to store or to obtain from self::$paths cache * ...
PHP
<?php namespace Asar; use \Asar\Message; use \Asar\Request\RequestInterface; /** */ class Request extends Message implements RequestInterface { private $path = '/', $method = 'GET', $params = array(); protected $headers = array('Accept' => 'text/html'), $content; function __...
PHP
<?php namespace Asar\PathDiscover; /** */ interface PathDiscoverInterface { function getPermaPath($path_params = array()); }
PHP
<?php namespace Asar; /** * This is a modified version of the SplClassLoader. The modification now allows * for loading single classes (e.g. Pimple.php). * * @author Wayne Duran <asartalo@projectweb.ph> * * SplClassLoader implementation that implements the technical interoperability * standards for PHP 5.3 na...
PHP
<?php namespace Asar; use \Asar\Message\MessageInterface; /** */ class Message implements MessageInterface { protected $headers = array(), $content = ''; function __construct($options = array()) { $this->setIfExists('content', $options, 'setContent'); $this->setIfExists('headers', $options, 'setHead...
PHP
<?php namespace Asar\Router; use \Asar\Router\RouterInterface; use \Asar\Router\Exception\ResourceNotFound; use \Asar\ResourceFactory; use \Asar\ResourceLister\ResourceListerInterface; use \Asar\Debug; use \Asar\Utility\String; /** */ class DefaultRouter implements RouterInterface { private $resource_factory, $...
PHP
<?php namespace Asar\Router\Exception; use \Asar\Router\Exception; /** */ class ResourceNotFound extends Exception {}
PHP
<?php namespace Asar\Router; /** */ interface RouterInterface { function route($app_name, $path, $map); }
PHP
<?php namespace Asar\Router; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\File; use \Asar\FileHelper\Exception\FileAlreadyExists; use \Asar\FileHelper\Exception\DirectoryAlreadyExists; use \Asar\FileHelper\Exception\ParentDirectoryDoesNotExist; /** */ class FileHelper { function create($filename, $contents) { try { return File::create($filenam...
PHP
<?php namespace Asar\Configurable; /** * An interface that allows classes to be configurable */ interface ConfigurableInterface { function setConfig($key, $value); function getConfig($key); }
PHP
<?php namespace Asar\MessageFilter; use \Asar\RequestFilter\RequestFilterInterface; use \Asar\ResponseFilter\ResponseFilterInterface; use \Asar\Request\RequestInterface; use \Asar\Response\ResponseInterface; use \Asar\Config\ConfigInterface; use \Asar\Debug; use \Asar\DebugPrinter\DebugPrinterInterface; use \Asar\Debu...
PHP
<?php namespace Asar\MessageFilter; use \Asar\RequestFilter\RequestFilterInterface; use \Asar\ResponseFilter\ResponseFilterInterface; use \Asar\Config\ConfigInterface; use \Asar\Request\RequestInterface; use \Asar\Response\ResponseInterface; use \Asar\Message\MessageInterface; use \Asar\Utility\String; /** */ class ...
PHP
<?php namespace Asar\Client\Exception; use \Asar\Client\Exception; /** */ class UnknownServerType extends Exception {}
PHP
<?php namespace Asar\Client; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\Resource\ResourceInterface; use \Asar\Resource\Exception\NotFound; use \Asar\Resource\Exception\MethodUndefined; use \Asar\Resource\Exception\ForwardRequest; use \Asar\Resource\Exception\Redirect; use \Asar\Config\ConfigInterface; use \Asar\Config; use \Asar\PathDiscover\PathDiscoverIn...
PHP
<?php namespace Asar\FileIncludeManager; /** * A wrapper interface for including files * @todo: maybe this can be removed in favor of SplClassLoader */ interface FileIncludeManagerInterface { function requireFileOnce($file); function includeFile($file); }
PHP
<?php namespace Asar\EnvironmentHelper; use \Asar\Config\ConfigInterface; use \Asar\RequestFactory; use \Asar\ResponseExporter; use \Asar\ApplicationScope; use \Asar\ApplicationInjector; /** * Environment helper that sets up the web server environment. This is * what is mostly used in the front controller. */ class...
PHP
<?php namespace Asar\EnvironmentHelper; use \Asar\Utility\Cli as UtilityCli; use \Asar\Utility\Cli\TaskFileLoader; /** * Environment Helper for setting up the CLI interface */ class Cli { private $cli, $args, $tasklists = array(), $task_file_loader; /** * @param Asar_Utility_Cli $cli * @param array $arg...
PHP
<?php namespace Asar\Resource; use \Asar\Request\RequestInterface; /** */ interface ResourceInterface { function handleRequest(RequestInterface $request); }
PHP
<?php namespace Asar\Resource\Exception; use \Asar\Resource\Exception; /** */ class ForwardRequest extends Exception { private $payload = array('request' => null); function setPayload($payload) { $this->payload = array_merge($this->payload, $payload); } function getPayload() { return $this->...
PHP
<?php namespace Asar\Resource\Exception; use \Asar\Resource\Exception; /** */ class Redirect extends Exception { private $payload = array('location' => null); function setPayload($payload) { $this->payload = array_merge($this->payload, $payload); } function getPayload() { return $this->paylo...
PHP
<?php namespace Asar\Resource\Exception; use \Asar\Resource\Exception; /** */ class MethodUndefined extends Exception {}
PHP
<?php namespace Asar\Resource\Exception; use \Asar\Resource\Exception; /** */ class NotFound extends Exception {}
PHP
<?php namespace Asar\Resource; /** */ class Exception extends \Asar\Exception {}
PHP
<?php namespace Asar; use \Asar\File\Exception\FileAlreadyExists; use \Asar\File\Exception\DirectoryNotFound; use \Asar\File\Exception\FileDoesNotExist; use \Asar\File\Exception as FileException; /** * A wrapper class for simplifying file creation and access * * EXAMPLE - File Creation * The following code crea...
PHP
<?php namespace Asar; /** */ require_once 'IncludePathManager.php'; class Toolset { private $include_path_manager; function getIncludePathManager() { if (!$this->include_path_manager) { $this->include_path_manager = new IncludePathManager; } return $this->include_path_manager; } }
PHP
<?php namespace Asar; class Injector extends \Pimple { function __construct( $server = array(), $get = array(), $post = array(), $files = array(), $session = array(), $cookie = array(), $env = array() ) { $this->server = $server; $this->get = $get; $this->post = $post; $this->f...
PHP
<?php namespace Asar; use \Asar\FileIncludeManager\FileIncludeManagerInterface; /** */ class FileIncludeManager implements FileIncludeManagerInterface { private $required_once = array(); function requireFileOnce($file) { // TODO: see if this performs better than require_once(); if (in_array($file, ...
PHP
<?php namespace Asar; /** */ class Debug implements \Iterator { private $data = array(), $valid = FALSE; function set($key, $value) { $this->data[$key] = $value; } function get($key) { if (isset($this->data[$key])) { return $this->data[$key]; } return null; } function re...
PHP
<?php namespace Asar\ResourceLister; /** */ interface ResourceListerInterface { function getResourceListFor($app_name); }
PHP
<?php namespace Asar; use \Asar\Resource\ResourceInterface; use \Asar\Client\Exception\UnknownServerType; use \Asar\Request; /** */ class Client { function sendRequest($server, $request) { if ($server instanceof ResourceInterface) { return $server->handleRequest($request); } throw new UnknownSer...
PHP