PHPFUI Build Status

PHP Wrapper for the Foundation CSS Framework

PHPFUI, PHP Foundation User Interface, is a 7.1 PHP library that produces HTML formated for Foundation. It does everything you need for a fully functional Foundation page, with the power of an OO language. It currently uses Foundation 6.6 and PHP 7.1 or higher.

"I was surprised that people were prepared to write HTML. In my initial requirements for this thing, I had assumed, as an absolute pre-condition, that nobody would have to do HTML or deal with URLs. If you use the original World Wide Web program, you never see a URL or have to deal with HTML. You're presented with the raw information. You then input more information. So you are linking information to information--like using a word processor. That was a surprise to me--that people were prepared to painstakingly write HTML."

Sir Tim Berners-Lee, inventor of the World Wide Web

Using PHPFUI for view output will produce 100% valid HTML and insulate you from future changes to Foundation, your custom HMTL layouts, CSS and JS library changes. You write to an abstract concept (I want a checkbox here), and the library will output a checkbox formatted for Foundation. You can inherit from CheckBox and add your own take on a checkbox, and when the graphic designer decides they have the most awesome checkbox ever, you simply change your CheckBox class, and it is changed on every page system wide.

Don't write HTML by hand!

Usage

namespace PHPFUI;
$page = new Page();
$form = new Form($page);
$fieldset = new FieldSet('A basic input form');
$time = new Input\Time($page, 'time', 'Enter A Time in 15 minute increments');
$time->setRequired();
$date = new Input\Date($page, 'date', 'Pick A Date');
$fieldset->add(new MultiColumn($time, $date));
$fieldset->add(new Input\TextArea('text', 'Enter some text'));
$fieldset->add(new Submit());
$form->add($fieldset);
$page->add($form);
$page->addStyleSheet('/css/styles.css');
echo $page;

Installation Instructions

composer require phpfui/phpfui

Then run update.php from the vendor/phpfui/phpfui directory and supply the path to your public directory / the directory for the various JS and CSS files PHPFUI uses. This will copy all required public files into your public directory. For example:

php vendor/phpfui/phpfui/update.php public/PHPFUI

The PHPFUI library defaults to your-public-directory/PHPFUI, it can be overridden, but it is suggested to use PHPFUI to keep everything in one place. update.php should be run when ever you update PHPFUI.

Versioning

Versioning will match the Foundation versions for Major semantic versions. PHPUI will always support the most recent version of Foundation possible for the Major version. PHPFUI Minor version will include breaking changes and may incorporate changes for the latest version of Foundation. The PHPFUI Patch version will include non breaking changes or additions. So PHPFUI Version 6.0.0 would be the first version of the library, 6.0.1 would be the first patch of PHPFUI. Both should work with any Foundation 6.x version. PHPFUI 6.1.0 would be a breaking change to PHPFUI, but still track Foundation 6.x. PHPFUI 7.0.0 would track Foundation 7.x series.

Depreciation and Foundation changes

Since major versions of Foundation have in the past depreciated and obsoleted things, PHPFUI will track the latest version of Foundation for class names and functionality. However, when Foundation makes a breaking change or removes something, PHPFUI will continue to support the old functionality as best as possible in the new Foundation framework. Depreciated classes will be put in the \PHPFUI\Vx namespace (where x would be the prior Major Foundation version containing that feature). So if something gets depreciated in a newer version of Foundation, you simply will need to change your code from \PHPFUI\Example to \PHPFUI\V6\Example. The depreciated namespace will only be supported for one Major version of PHPFUI, so it is recommended you migrate off of it in a timely manor.

Documentation

Via PHPFUI/InstaDoc

Examples

Add the following files to a public directory for testing

Unit Testing

Full unit testing using phpfui/html-unit-tester

License

PHPFUI is distributed under the MIT License.


PHPFUI\InstaDoc Library Build Status

A quick and easy way to add documentation to your PHP project

We all document our code with PHP DocBlocks but we never seem to actually generate the documentation and add it to our project. Why? It simply takes too much time (over a minute), so we put it off till later, and later never comes.

But with PHPFUI\InstaDoc, you can document your site in about a minute (OK, maybe 2). The steps involved:

  • Install PHPFUI\InstaDoc via Composer (30 seconds)
  • Run installation script (30 seconds)
  • Create document page (1 minute, 5 lines of code)

Two minutes to usable documentation with the following features:

PHPFUI\InstaDoc Features

  • Always up to date, even with code that is not yet checked in
  • Quick access to highlighted PHP source with user selectable highlighting
  • Quick access to the file's git history for the local repo
  • Documents all projects loaded via Composer automatically
  • Tabbed documentation so you are not looking at irrelevant methods
  • Alphabetized everything, no more searching unalphabetized pages!
  • Support for markdown and custom markdown pages
  • Ability to generate static html files for high volume sites
  • Add any local repo directories
  • Remove any Composer project you don't care about
  • 5+ line config compatible with all PHP frameworks, or standalone
  • Completely configurable UI if you don't like the default
  • Uses Foundation CSS framework for a great experience on mobile

Install PHPFUI\InstaDoc

composer require phpfui/InstaDoc

Run Installation Script

Once installed, you need to run an installation script to copy static files to your public directory. From the project root, run the following:

php vendor/phpfui/instadoc/install.php yourPublicDirectory/subDirectory

Example: php vendor/phpfui/instadoc/install.php public/PHPFUI will add all needed files to public/PHPFUI, which will avoid any conflicts with your current files. You can specify any directory by using \PHPFUI\Page::setResourcePath, but PHPFUI is recomended to keep things simple.

Create Document Page

PHPFUI\InstaDoc does not reply on any framework and can run on a standalone page. It is recommended that you do not make your documentation public, as PHPFUI\InstaDoc will display PHP source files. How you restrict access to the page is up to you. The following does not restrict access and is simply an example:

<?php
include 'yourAutoLoader.php';

// pass the directory containing your composer.json file
$fileManager = new \PHPFUI\InstaDoc\FileManager('../');

// add you App class tree in
$fileManager->addNamespace('App', '../App', true);

// load you cached files
$fileManager->load();

// get the controller
$controller = new \PHPFUI\InstaDoc\Controller($fileManager);

// display will return a fully formed page
echo $controller->display();

That is it. You are done!

Example and Full Documentation

PHPFUI/InstaDoc

Package Documentation

  • \DeepCopy Readme

    DeepCopy

    DeepCopy helps you create deep copies (clones) of your objects. It is designed to handle cycles in the association graph.

    Build Status Coverage Status Scrutinizer Quality Score Total Downloads

    Table of Contents

    1. How
    2. Why
      1. Using simply clone
      2. Overridding __clone()
      3. With DeepCopy
    3. How it works
    4. Going further
      1. Matchers
        1. Property name
        2. Specific property
        3. Type
      2. Filters
        1. SetNullFilter
        2. KeepFilter
        3. DoctrineCollectionFilter
        4. DoctrineEmptyCollectionFilter
        5. DoctrineProxyFilter
        6. ReplaceFilter
        7. ShallowCopyFilter
    5. Edge cases
    6. Contributing
      1. Tests

    How?

    Install with Composer:

    composer require myclabs/deep-copy

    Use simply:

    use DeepCopy\DeepCopy;
    
    $copier = new DeepCopy();
    $myCopy = $copier->copy($myObject);

    Why?

    • How do you create copies of your objects?
    $myCopy = clone $myObject;
    • How do you create deep copies of your objects (i.e. copying also all the objects referenced in the properties)?

    You use __clone() and implement the behavior yourself.

    • But how do you handle cycles in the association graph?

    Now you're in for a big mess :(

    association graph

    Using simply clone

    Using clone

    Overridding __clone()

    Overridding __clone

    With DeepCopy

    With DeepCopy

    How it works

    DeepCopy recursively traverses all the object's properties and clones them. To avoid cloning the same object twice it keeps a hash map of all instances and thus preserves the object graph.

    To use it:

    use function DeepCopy\deep_copy;
    
    $copy = deep_copy($var);

    Alternatively, you can create your own DeepCopy instance to configure it differently for example:

    use DeepCopy\DeepCopy;
    
    $copier = new DeepCopy(true);
    
    $copy = $copier->copy($var);

    You may want to roll your own deep copy function:

    namespace Acme;
    
    use DeepCopy\DeepCopy;
    
    function deep_copy($var)
    {
        static $copier = null;
    
        if (null === $copier) {
            $copier = new DeepCopy(true);
        }
    
        return $copier->copy($var);
    }

    Going further

    You can add filters to customize the copy process.

    The method to add a filter is DeepCopy\DeepCopy::addFilter($filter, $matcher), with $filter implementing DeepCopy\Filter\Filter and $matcher implementing DeepCopy\Matcher\Matcher.

    We provide some generic filters and matchers.

    Matchers

    • DeepCopy\Matcher applies on a object attribute.
    • DeepCopy\TypeMatcher applies on any element found in graph, including array elements.

    Property name

    The PropertyNameMatcher will match a property by its name:

    use DeepCopy\Matcher\PropertyNameMatcher;
    
    // Will apply a filter to any property of any objects named "id"
    $matcher = new PropertyNameMatcher('id');

    Specific property

    The PropertyMatcher will match a specific property of a specific class:

    use DeepCopy\Matcher\PropertyMatcher;
    
    // Will apply a filter to the property "id" of any objects of the class "MyClass"
    $matcher = new PropertyMatcher('MyClass', 'id');

    Type

    The TypeMatcher will match any element by its type (instance of a class or any value that could be parameter of gettype() function):

    use DeepCopy\TypeMatcher\TypeMatcher;
    
    // Will apply a filter to any object that is an instance of Doctrine\Common\Collections\Collection
    $matcher = new TypeMatcher('Doctrine\Common\Collections\Collection');

    Filters

    • DeepCopy\Filter applies a transformation to the object attribute matched by DeepCopy\Matcher
    • DeepCopy\TypeFilter applies a transformation to any element matched by DeepCopy\TypeMatcher

    SetNullFilter (filter)

    Let's say for example that you are copying a database record (or a Doctrine entity), so you want the copy not to have any ID:

    use DeepCopy\DeepCopy;
    use DeepCopy\Filter\SetNullFilter;
    use DeepCopy\Matcher\PropertyNameMatcher;
    
    $object = MyClass::load(123);
    echo $object->id; // 123
    
    $copier = new DeepCopy();
    $copier->addFilter(new SetNullFilter(), new PropertyNameMatcher('id'));
    
    $copy = $copier->copy($object);
    
    echo $copy->id; // null

    KeepFilter (filter)

    If you want a property to remain untouched (for example, an association to an object):

    use DeepCopy\DeepCopy;
    use DeepCopy\Filter\KeepFilter;
    use DeepCopy\Matcher\PropertyMatcher;
    
    $copier = new DeepCopy();
    $copier->addFilter(new KeepFilter(), new PropertyMatcher('MyClass', 'category'));
    
    $copy = $copier->copy($object);
    // $copy->category has not been touched

    DoctrineCollectionFilter (filter)

    If you use Doctrine and want to copy an entity, you will need to use the DoctrineCollectionFilter:

    use DeepCopy\DeepCopy;
    use DeepCopy\Filter\Doctrine\DoctrineCollectionFilter;
    use DeepCopy\Matcher\PropertyTypeMatcher;
    
    $copier = new DeepCopy();
    $copier->addFilter(new DoctrineCollectionFilter(), new PropertyTypeMatcher('Doctrine\Common\Collections\Collection'));
    
    $copy = $copier->copy($object);

    DoctrineEmptyCollectionFilter (filter)

    If you use Doctrine and want to copy an entity who contains a Collection that you want to be reset, you can use the DoctrineEmptyCollectionFilter

    use DeepCopy\DeepCopy;
    use DeepCopy\Filter\Doctrine\DoctrineEmptyCollectionFilter;
    use DeepCopy\Matcher\PropertyMatcher;
    
    $copier = new DeepCopy();
    $copier->addFilter(new DoctrineEmptyCollectionFilter(), new PropertyMatcher('MyClass', 'myProperty'));
    
    $copy = $copier->copy($object);
    
    // $copy->myProperty will return an empty collection

    DoctrineProxyFilter (filter)

    If you use Doctrine and use cloning on lazy loaded entities, you might encounter errors mentioning missing fields on a Doctrine proxy class (...\__CG__\Proxy). You can use the DoctrineProxyFilter to load the actual entity behind the Doctrine proxy class. Make sure, though, to put this as one of your very first filters in the filter chain so that the entity is loaded before other filters are applied!

    use DeepCopy\DeepCopy;
    use DeepCopy\Filter\Doctrine\DoctrineProxyFilter;
    use DeepCopy\Matcher\Doctrine\DoctrineProxyMatcher;
    
    $copier = new DeepCopy();
    $copier->addFilter(new DoctrineProxyFilter(), new DoctrineProxyMatcher());
    
    $copy = $copier->copy($object);
    
    // $copy should now contain a clone of all entities, including those that were not yet fully loaded.

    ReplaceFilter (type filter)

    1. If you want to replace the value of a property:
    use DeepCopy\DeepCopy;
    use DeepCopy\Filter\ReplaceFilter;
    use DeepCopy\Matcher\PropertyMatcher;
    
    $copier = new DeepCopy();
    $callback = function ($currentValue) {
      return $currentValue . ' (copy)'
    };
    $copier->addFilter(new ReplaceFilter($callback), new PropertyMatcher('MyClass', 'title'));
    
    $copy = $copier->copy($object);
    
    // $copy->title will contain the data returned by the callback, e.g. 'The title (copy)'
    1. If you want to replace whole element:
    use DeepCopy\DeepCopy;
    use DeepCopy\TypeFilter\ReplaceFilter;
    use DeepCopy\TypeMatcher\TypeMatcher;
    
    $copier = new DeepCopy();
    $callback = function (MyClass $myClass) {
      return get_class($myClass);
    };
    $copier->addTypeFilter(new ReplaceFilter($callback), new TypeMatcher('MyClass'));
    
    $copy = $copier->copy([new MyClass, 'some string', new MyClass]);
    
    // $copy will contain ['MyClass', 'some string', 'MyClass']

    The $callback parameter of the ReplaceFilter constructor accepts any PHP callable.

    ShallowCopyFilter (type filter)

    Stop DeepCopy from recursively copying element, using standard clone instead:

    use DeepCopy\DeepCopy;
    use DeepCopy\TypeFilter\ShallowCopyFilter;
    use DeepCopy\TypeMatcher\TypeMatcher;
    use Mockery as m;
    
    $this->deepCopy = new DeepCopy();
    $this->deepCopy->addTypeFilter(
        new ShallowCopyFilter,
        new TypeMatcher(m\MockInterface::class)
    );
    
    $myServiceWithMocks = new MyService(m::mock(MyDependency1::class), m::mock(MyDependency2::class));
    // All mocks will be just cloned, not deep copied

    Edge cases

    The following structures cannot be deep-copied with PHP Reflection. As a result they are shallow cloned and filters are not applied. There is two ways for you to handle them:

    • Implement your own __clone() method
    • Use a filter with a type matcher

    Contributing

    DeepCopy is distributed under the MIT license.

    Tests

    Running the tests is simple:

    vendor/bin/phpunit

    Support

    Get professional support via the Tidelift Subscription.

  • \Highlight Readme

    highlight.php

    Build Status Latest Packagist release Monthly downloads on Packagist

    highlight.php is a server side code highlighter written in PHP that currently supports 185 languages. It's a port of highlight.js by Ivan Sagalaev that makes full use of the language and style definitions of the original JavaScript project.

    Table of Contents

    Installation + Setup

    The recommended approach is to install the project through Composer.

    composer require scrivo/highlight.php

    If you're not using Composer, ensure that the classes defined in the Highlight namespace can be found either by inclusion or by an autoloader. A trivial autoloader for this purpose is included in this project as Highlight\Autoloader.php

    Composer Version Constraints

    When requiring this project in your composer.json, it is recommended you use the caret version range and use only the major and minor values; i.e. ^9.14.

    It's come to our attention that a lot of tutorials and projects out there are locking themselves into highly specific versions of this project; e.g. "scrivo/highlight.php": "v9.12.0.1". Please do not do this or encourage it. We promise a reliable backward compatibility policy so there's no reason to lock yourself to such a specific version. By doing this, you are preventing yourself or your users from receiving updates to language definitions and bug fixes.

    Usage

    The \Highlight\Highlighter class contains the highlighting functionality. You can choose between two highlighting modes:

    1. explicit mode
    2. automatic language detection mode

    Explicit Mode

    In explicit mode, you must define which language you will be highlighting as.

    // Instantiate the Highlighter.
    $hl = new \Highlight\Highlighter();
    $code = file_get_contents('some_ruby_script.rb');
    
    try {
        // Highlight some code.
        $highlighted = $hl->highlight('ruby', $code);
    
        echo "<pre><code class=\"hljs {$highlighted->language}\">";
        echo $highlighted->value;
        echo "</code></pre>";
    }
    catch (DomainException $e) {
        // This is thrown if the specified language does not exist
    
        echo "<pre><code>";
        echo $code;
        echo "</code></pre>";
    }

    Automatic Language Detection Mode

    Alternatively you can use the automatic detection mode, which highlights your code with the language the library thinks is best.

    Warning: You must supply a list of languages that the Highlighter will pick from. This occurs in a brute force fashion and the language with the most accurate result will be selected. This is extremely inefficient as you supply more languages and may not always be 100% accurate.

    It is highly recommended you explicitly choose the language or limit the number of languages to automatically detect to reduce the number of inaccuracies.

    $hl = new \Highlight\Highlighter();
    $hl->setAutodetectLanguages(array('ruby', 'python', 'perl'));
    
    $highlighted = $hl->highlightAuto(file_get_contents('some_ruby_script.rb'));
    
    echo "<pre><code class=\"hljs {$highlighted->language}\">";
    echo $highlighted->value;
    echo "</code></pre>";

    Stylesheets

    The same stylesheets available in the highlight.js project are available in the styles directory of this project and may be included in your own CSS or made accessible to your web server.

    Highlighter Utilities

    The core of the project is loyal port of highlight.js and is available under the main Highlight namespace. A series of convenience functions are provided under the HighlightUtilities namespace to introduce additional functionality without the need for another dependency.

    Available functions:

    Versioning

    This project will follow the same version numbers as the highlight.js project with regards to languages, meaning that a language definition available in highlight.js 9.12.0 will be available in highlight.php 9.12.0. However, there are times where bugs may arise in this project or its translated definition files, so there'll be one more number appended to the version number. For example, version 9.12.0.1 will contain all of the same languages as highlight.js 9.12.0 but also contain fixes solely to this project. This is done so this project can have version bumps without conflicts should highlight.js release version 9.12.1.

    Backward Compatibility Promise

    Despite the fact that the semantic versioning used in this project mirrors that of highlight.js, this project will adhere to Symfony's Backward Compatibility Promise. You can rest assured that there will be no breaking changes during 9.x and any deprecations will be marked with @deprecated and won't be removed until the next major release.

    Some History

    Geert Bergman Sep 30, 2013

    JavaScript code highlighting is very convenient and in many cases just what you want to use. Especially for programming blogs I would not advice you to use otherwise. But there are occasions where you're better off with a more 'static' approach, for instance if you want to send highlighted code in an email or for API documents. For this I needed a code highlighting program preferably written in PHP.

    I couldn't found any satisfactory PHP solution so I decided to port one from JavaScript. After some comparison of different highlighting programs based on license, technology, language support highlight.js came out most favorable in my opinion.

    It was my decision not to make a PHP highlighter but to do a port of highlight.js, these are different things. The goal was to make it work exactly as highlight.js to make as much use as possible of the language definitions and CSS files of the original program.

    Happy coding!

    License

    BSD

  • \PHPFUI Readme

    PHPFUI Build Status

    PHP Wrapper for the Foundation CSS Framework

    PHPFUI, PHP Foundation User Interface, is a 7.1 PHP library that produces HTML formated for Foundation. It does everything you need for a fully functional Foundation page, with the power of an OO language. It currently uses Foundation 6.6 and PHP 7.1 or higher.

    "I was surprised that people were prepared to write HTML. In my initial requirements for this thing, I had assumed, as an absolute pre-condition, that nobody would have to do HTML or deal with URLs. If you use the original World Wide Web program, you never see a URL or have to deal with HTML. You're presented with the raw information. You then input more information. So you are linking information to information--like using a word processor. That was a surprise to me--that people were prepared to painstakingly write HTML."

    Sir Tim Berners-Lee, inventor of the World Wide Web

    Using PHPFUI for view output will produce 100% valid HTML and insulate you from future changes to Foundation, your custom HMTL layouts, CSS and JS library changes. You write to an abstract concept (I want a checkbox here), and the library will output a checkbox formatted for Foundation. You can inherit from CheckBox and add your own take on a checkbox, and when the graphic designer decides they have the most awesome checkbox ever, you simply change your CheckBox class, and it is changed on every page system wide.

    Don't write HTML by hand!

    Usage

    namespace PHPFUI;
    $page = new Page();
    $form = new Form($page);
    $fieldset = new FieldSet('A basic input form');
    $time = new Input\Time($page, 'time', 'Enter A Time in 15 minute increments');
    $time->setRequired();
    $date = new Input\Date($page, 'date', 'Pick A Date');
    $fieldset->add(new MultiColumn($time, $date));
    $fieldset->add(new Input\TextArea('text', 'Enter some text'));
    $fieldset->add(new Submit());
    $form->add($fieldset);
    $page->add($form);
    $page->addStyleSheet('/css/styles.css');
    echo $page;

    Installation Instructions

    composer require phpfui/phpfui

    Then run update.php from the vendor/phpfui/phpfui directory and supply the path to your public directory / the directory for the various JS and CSS files PHPFUI uses. This will copy all required public files into your public directory. For example:

    php vendor/phpfui/phpfui/update.php public/PHPFUI

    The PHPFUI library defaults to your-public-directory/PHPFUI, it can be overridden, but it is suggested to use PHPFUI to keep everything in one place. update.php should be run when ever you update PHPFUI.

    Versioning

    Versioning will match the Foundation versions for Major semantic versions. PHPUI will always support the most recent version of Foundation possible for the Major version. PHPFUI Minor version will include breaking changes and may incorporate changes for the latest version of Foundation. The PHPFUI Patch version will include non breaking changes or additions. So PHPFUI Version 6.0.0 would be the first version of the library, 6.0.1 would be the first patch of PHPFUI. Both should work with any Foundation 6.x version. PHPFUI 6.1.0 would be a breaking change to PHPFUI, but still track Foundation 6.x. PHPFUI 7.0.0 would track Foundation 7.x series.

    Depreciation and Foundation changes

    Since major versions of Foundation have in the past depreciated and obsoleted things, PHPFUI will track the latest version of Foundation for class names and functionality. However, when Foundation makes a breaking change or removes something, PHPFUI will continue to support the old functionality as best as possible in the new Foundation framework. Depreciated classes will be put in the \PHPFUI\Vx namespace (where x would be the prior Major Foundation version containing that feature). So if something gets depreciated in a newer version of Foundation, you simply will need to change your code from \PHPFUI\Example to \PHPFUI\V6\Example. The depreciated namespace will only be supported for one Major version of PHPFUI, so it is recommended you migrate off of it in a timely manor.

    Documentation

    Via PHPFUI/InstaDoc

    Examples

    Add the following files to a public directory for testing

    Unit Testing

    Full unit testing using phpfui/html-unit-tester

    License

    PHPFUI is distributed under the MIT License.

  • \PHPFUI\HTMLUnitTester Readme

    PHPFUI\HTMLUnitTester Build Status

    PHPUnit Testing extensions for HMTL and CSS. PHPFUI\HTMLUnitTester allows you to unit test HTML and CSS for errors and warnings. Often simple errors in HTML or CSS create hard to debug issues where a simple check will reveal bad code.

    This package will check detect errors and warnings in HTML and CSS in stand alone strings, files or urls.

    Requirements

    • PHP 7.1 or higher
    • PHPUnit 7 or higher

    For the best performanance, a local install of https://github.com/validator/validator is recommended.

    Installation

    composer require phpfui/html-unit-tester

    Configuration

    It is recommended you run https://github.com/validator/validator locally. Install Java and download the .jar file. Run with the following command:

    java -Xss512k -cp vnu.jar nu.validator.servlet.Main 8888

    If you are not using a local server, you will need to add the following lines to your phpunit.xml config in the phpunit element:

    <php>
      <env name="PHPFUI\HTMLUnitTester\Extensions_url" value="http://validator.w3.org/nu"/>
      <env name="PHPFUI\HTMLUnitTester\Extensions_delay" value="500000"/>
    </php>

    Usage

    Extend your unit tests from \PHPFUI\HTMLUnitTester\Extensions

    class UnitTest extends \PHPFUI\HTMLUnitTester\Extensions
      {
      public function testValidHtml()
        {
        $this->assertValidHtml('<h1>Header</h1>');
        $this->assertValidHtml('<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Title</title></head><body><div>This is a test</div></body></html>');
        }
      }

    You can use any of the following asserts:

    • assertNotWarningCss
    • assertNotWarningCssFile
    • assertNotWarningCssUrl
    • assertNotWarningFile
    • assertNotWarningHtml
    • assertNotWarningUrl
    • assertValidCss
    • assertValidCssFile
    • assertValidCssUrl
    • assertValidFile
    • assertValidHtml
    • assertValidUrl

    Examples

    See examples

    Documentation

    Full documentation at PHPFUI\HTMLUnitTester

  • \PHPFUI\InstaDoc Readme

    PHPFUI\InstaDoc Library Build Status

    A quick and easy way to add documentation to your PHP project

    We all document our code with PHP DocBlocks but we never seem to actually generate the documentation and add it to our project. Why? It simply takes too much time (over a minute), so we put it off till later, and later never comes.

    But with PHPFUI\InstaDoc, you can document your site in about a minute (OK, maybe 2). The steps involved:

    • Install PHPFUI\InstaDoc via Composer (30 seconds)
    • Run installation script (30 seconds)
    • Create document page (1 minute, 5 lines of code)

    Two minutes to usable documentation with the following features:

    PHPFUI\InstaDoc Features

    • Always up to date, even with code that is not yet checked in
    • Quick access to highlighted PHP source with user selectable highlighting
    • Quick access to the file's git history for the local repo
    • Documents all projects loaded via Composer automatically
    • Tabbed documentation so you are not looking at irrelevant methods
    • Alphabetized everything, no more searching unalphabetized pages!
    • Support for markdown and custom markdown pages
    • Ability to generate static html files for high volume sites
    • Add any local repo directories
    • Remove any Composer project you don't care about
    • 5+ line config compatible with all PHP frameworks, or standalone
    • Completely configurable UI if you don't like the default
    • Uses Foundation CSS framework for a great experience on mobile

    Install PHPFUI\InstaDoc

    composer require phpfui/InstaDoc

    Run Installation Script

    Once installed, you need to run an installation script to copy static files to your public directory. From the project root, run the following:

    php vendor/phpfui/instadoc/install.php yourPublicDirectory/subDirectory

    Example: php vendor/phpfui/instadoc/install.php public/PHPFUI will add all needed files to public/PHPFUI, which will avoid any conflicts with your current files. You can specify any directory by using \PHPFUI\Page::setResourcePath, but PHPFUI is recomended to keep things simple.

    Create Document Page

    PHPFUI\InstaDoc does not reply on any framework and can run on a standalone page. It is recommended that you do not make your documentation public, as PHPFUI\InstaDoc will display PHP source files. How you restrict access to the page is up to you. The following does not restrict access and is simply an example:

    <?php
    include 'yourAutoLoader.php';
    
    // pass the directory containing your composer.json file
    $fileManager = new \PHPFUI\InstaDoc\FileManager('../');
    
    // add you App class tree in
    $fileManager->addNamespace('App', '../App', true);
    
    // load you cached files
    $fileManager->load();
    
    // get the controller
    $controller = new \PHPFUI\InstaDoc\Controller($fileManager);
    
    // display will return a fully formed page
    echo $controller->display();

    That is it. You are done!

    Example and Full Documentation

    PHPFUI/InstaDoc

  • \PHPUnit Readme

    PHPUnit

    PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.

    Latest Stable Version Minimum PHP Version Build Status CI Status Type Coverage

    Installation

    We distribute a PHP Archive (PHAR) that has all required (as well as some optional) dependencies of PHPUnit 8.5 bundled in a single file:

    $ wget https://phar.phpunit.de/phpunit-8.5.phar
    
    $ php phpunit-8.5.phar --version

    Alternatively, you may use Composer to download and install PHPUnit as well as its dependencies. Please refer to the "Getting Started" guide for details on how to install PHPUnit.

    Contribute

    Please refer to CONTRIBUTING.md for information on how to contribute to PHPUnit and its related projects.

    List of Contributors

    Thanks to everyone who has contributed to PHPUnit! You can find a detailed list of contributors on every PHPUnit related package on GitHub. This list shows only the major components:

    A very special thanks to everyone who has contributed to the documentation and helps maintain the translations:

  • \Symfony\Component\Process Readme

    Process Component

    The Process component executes commands in sub-processes.

    Resources

  • \Webmozart\Assert Readme

    Webmozart Assert

    Build Status Build status Code Coverage Latest Stable Version Total Downloads

    This library contains efficient assertions to test the input and output of your methods. With these assertions, you can greatly reduce the amount of coding needed to write a safe implementation.

    All assertions in the Assert class throw an \InvalidArgumentException if they fail.

    FAQ

    What's the difference to beberlei/assert?

    This library is heavily inspired by Benjamin Eberlei's wonderful assert package, but fixes a usability issue with error messages that can't be fixed there without breaking backwards compatibility.

    This package features usable error messages by default. However, you can also easily write custom error messages:

    Assert::string($path, 'The path is expected to be a string. Got: %s');

    In beberlei/assert, the ordering of the %s placeholders is different for every assertion. This package, on the contrary, provides consistent placeholder ordering for all assertions:

    • %s: The tested value as string, e.g. "/foo/bar".
    • %2$s, %3$s, ...: Additional assertion-specific values, e.g. the minimum/maximum length, allowed values, etc.

    Check the source code of the assertions to find out details about the additional available placeholders.

    Installation

    Use Composer to install the package:

    $ composer require webmozart/assert

    Example

    use Webmozart\Assert\Assert;
    
    class Employee
    {
        public function __construct($id)
        {
            Assert::integer($id, 'The employee ID must be an integer. Got: %s');
            Assert::greaterThan($id, 0, 'The employee ID must be a positive integer. Got: %s');
        }
    }

    If you create an employee with an invalid ID, an exception is thrown:

    new Employee('foobar');
    // => InvalidArgumentException:
    //    The employee ID must be an integer. Got: string
    
    new Employee(-10);
    // => InvalidArgumentException:
    //    The employee ID must be a positive integer. Got: -10

    Assertions

    The Assert class provides the following assertions:

    Type Assertions

    Method Description
    string($value, $message = '') Check that a value is a string
    stringNotEmpty($value, $message = '') Check that a value is a non-empty string
    integer($value, $message = '') Check that a value is an integer
    integerish($value, $message = '') Check that a value casts to an integer
    float($value, $message = '') Check that a value is a float
    numeric($value, $message = '') Check that a value is numeric
    natural($value, $message= ''') Check that a value is a non-negative integer
    boolean($value, $message = '') Check that a value is a boolean
    scalar($value, $message = '') Check that a value is a scalar
    object($value, $message = '') Check that a value is an object
    resource($value, $type = null, $message = '') Check that a value is a resource
    isCallable($value, $message = '') Check that a value is a callable
    isArray($value, $message = '') Check that a value is an array
    isTraversable($value, $message = '') (deprecated) Check that a value is an array or a \Traversable
    isIterable($value, $message = '') Check that a value is an array or a \Traversable
    isCountable($value, $message = '') Check that a value is an array or a \Countable
    isInstanceOf($value, $class, $message = '') Check that a value is an instanceof a class
    isInstanceOfAny($value, array $classes, $message = '') Check that a value is an instanceof a at least one class on the array of classes
    notInstanceOf($value, $class, $message = '') Check that a value is not an instanceof a class
    isArrayAccessible($value, $message = '') Check that a value can be accessed as an array
    uniqueValues($values, $message = '') Check that the given array contains unique values

    Comparison Assertions

    Method Description
    true($value, $message = '') Check that a value is true
    false($value, $message = '') Check that a value is false
    null($value, $message = '') Check that a value is null
    notNull($value, $message = '') Check that a value is not null
    isEmpty($value, $message = '') Check that a value is empty()
    notEmpty($value, $message = '') Check that a value is not empty()
    eq($value, $value2, $message = '') Check that a value equals another (==)
    notEq($value, $value2, $message = '') Check that a value does not equal another (!=)
    same($value, $value2, $message = '') Check that a value is identical to another (===)
    notSame($value, $value2, $message = '') Check that a value is not identical to another (!==)
    greaterThan($value, $value2, $message = '') Check that a value is greater than another
    greaterThanEq($value, $value2, $message = '') Check that a value is greater than or equal to another
    lessThan($value, $value2, $message = '') Check that a value is less than another
    lessThanEq($value, $value2, $message = '') Check that a value is less than or equal to another
    range($value, $min, $max, $message = '') Check that a value is within a range
    oneOf($value, array $values, $message = '') Check that a value is one of a list of values

    String Assertions

    You should check that a value is a string with Assert::string() before making any of the following assertions.

    Method Description
    contains($value, $subString, $message = '') Check that a string contains a substring
    notContains($value, $subString, $message = '') Check that a string does not contains a substring
    startsWith($value, $prefix, $message = '') Check that a string has a prefix
    startsWithLetter($value, $message = '') Check that a string starts with a letter
    endsWith($value, $suffix, $message = '') Check that a string has a suffix
    regex($value, $pattern, $message = '') Check that a string matches a regular expression
    notRegex($value, $pattern, $message = '') Check that a string does not match a regular expression
    unicodeLetters($value, $message = '') Check that a string contains Unicode letters only
    alpha($value, $message = '') Check that a string contains letters only
    digits($value, $message = '') Check that a string contains digits only
    alnum($value, $message = '') Check that a string contains letters and digits only
    lower($value, $message = '') Check that a string contains lowercase characters only
    upper($value, $message = '') Check that a string contains uppercase characters only
    length($value, $length, $message = '') Check that a string has a certain number of characters
    minLength($value, $min, $message = '') Check that a string has at least a certain number of characters
    maxLength($value, $max, $message = '') Check that a string has at most a certain number of characters
    lengthBetween($value, $min, $max, $message = '') Check that a string has a length in the given range
    uuid($value, $message = '') Check that a string is a valid UUID
    ip($value, $message = '') Check that a string is a valid IP (either IPv4 or IPv6)
    ipv4($value, $message = '') Check that a string is a valid IPv4
    ipv6($value, $message = '') Check that a string is a valid IPv6
    email($value, $message = '') Check that a string is a valid e-mail address
    notWhitespaceOnly($value, $message = '') Check that a string contains at least one non-whitespace character

    File Assertions

    Method Description
    fileExists($value, $message = '') Check that a value is an existing path
    file($value, $message = '') Check that a value is an existing file
    directory($value, $message = '') Check that a value is an existing directory
    readable($value, $message = '') Check that a value is a readable path
    writable($value, $message = '') Check that a value is a writable path

    Object Assertions

    Method Description
    classExists($value, $message = '') Check that a value is an existing class name
    subclassOf($value, $class, $message = '') Check that a class is a subclass of another
    interfaceExists($value, $message = '') Check that a value is an existing interface name
    implementsInterface($value, $class, $message = '') Check that a class implements an interface
    propertyExists($value, $property, $message = '') Check that a property exists in a class/object
    propertyNotExists($value, $property, $message = '') Check that a property does not exist in a class/object
    methodExists($value, $method, $message = '') Check that a method exists in a class/object
    methodNotExists($value, $method, $message = '') Check that a method does not exist in a class/object

    Array Assertions

    Method Description
    keyExists($array, $key, $message = '') Check that a key exists in an array
    keyNotExists($array, $key, $message = '') Check that a key does not exist in an array
    validArrayKey($key, $message = '') Check that a value is a valid array key (int or string)
    count($array, $number, $message = '') Check that an array contains a specific number of elements
    minCount($array, $min, $message = '') Check that an array contains at least a certain number of elements
    maxCount($array, $max, $message = '') Check that an array contains at most a certain number of elements
    countBetween($array, $min, $max, $message = '') Check that an array has a count in the given range
    isList($array, $message = '') Check that an array is a non-associative list
    isNonEmptyList($array, $message = '') Check that an array is a non-associative list, and not empty
    isMap($array, $message = '') Check that an array is associative and has strings as keys
    isNonEmptyMap($array, $message = '') Check that an array is associative and has strings as keys, and is not empty

    Function Assertions

    Method Description
    throws($closure, $class, $message = '') Check that a function throws a certain exception. Subclasses of the exception class will be accepted.

    Collection Assertions

    All of the above assertions can be prefixed with all*() to test the contents of an array or a \Traversable:

    Assert::allIsInstanceOf($employees, 'Acme\Employee');

    Nullable Assertions

    All of the above assertions can be prefixed with nullOr*() to run the assertion only if it the value is not null:

    Assert::nullOrString($middleName, 'The middle name must be a string or null. Got: %s');

    Extending Assert

    The Assert class comes with a few methods, which can be overridden to change the class behaviour. You can also extend it to add your own assertions.

    Overriding methods

    Overriding the following methods in your assertion class allows you to change the behaviour of the assertions:

    • public static function __callStatic($name, $arguments)
      • This method is used to 'create' the nullOr and all versions of the assertions.
    • protected static function valueToString($value)
      • This method is used for error messages, to convert the value to a string value for displaying. You could use this for representing a value object with a __toString method for example.
    • protected static function typeToString($value)
      • This method is used for error messages, to convert the a value to a string representing its type.
    • protected static function strlen($value)
      • This method is used to calculate string lenght for relevant methods, using the mb_strlen if available and usefull.
    • protected static function reportInvalidArgument($message)
      • This method is called when an assertion fails, with the specified error message. Here you can throw your own exception, or log something.

    Authors

    Contribute

    Contributions to the package are always welcome!

    License

    All contents of this package are licensed under the MIT license.

  • \phpDocumentor\Reflection Readme

    The ReflectionDocBlock Component Build Status

    Introduction

    The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser that is 100% compatible with the PHPDoc standard.

    With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

    Installation

    composer require phpdocumentor/reflection-docblock

    Usage

    In order to parse the DocBlock one needs a DocBlockFactory that can be instantiated using its createInstance factory method like this:

    $factory  = \phpDocumentor\Reflection\DocBlockFactory::createInstance();

    Then we can use the create method of the factory to interpret the DocBlock. Please note that it is also possible to provide a class that has the getDocComment() method, such as an object of type ReflectionClass, the create method will read that if it exists.

    $docComment = <<<DOCCOMMENT
    /**
     * This is an example of a summary.
     *
     * This is a Description. A Summary and Description are separated by either
     * two subsequent newlines (thus a whiteline in between as can be seen in this
     * example), or when the Summary ends with a dot (`.`) and some form of
     * whitespace.
     */
    DOCCOMMENT;
    
    $docblock = $factory->create($docComment);

    The create method will yield an object of type \phpDocumentor\Reflection\DocBlock whose methods can be queried:

    // Contains the summary for this DocBlock
    $summary = $docblock->getSummary();
    
    // Contains \phpDocumentor\Reflection\DocBlock\Description object
    $description = $docblock->getDescription();
    
    // You can either cast it to string
    $description = (string) $docblock->getDescription();
    
    // Or use the render method to get a string representation of the Description.
    $description = $docblock->getDescription()->render();

    For more examples it would be best to review the scripts in the /examples folder.

© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only