PHP code example of rsc / components

1. Go to this page and download the library: Download rsc/components library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rsc / components example snippets



// Basic/Link.test.php

 = new Rsc\Components\Model\Basic\Link();
$a->setVariables(['href' => 'http://www.google.com', 'text' => 'test']);

$rendered = $a->render();

// Basic assertions are good enough for this use case
assert( (bool) stristr($rendered, '<a') );
assert( (bool) stristr($rendered, 'href="') );
assert( (bool) stristr($rendered, 'http://www.google.com') );
assert( (bool) stristr($rendered, 'test') );


// Components/Model/Basic/Link.php

namespace Rsc\Components\Model\Basic;
use Rsc\Components\Base;

class Link extends Base
{
    // Template file, relative to Components/view/frontend/Components
    protected $file = 'Basic/Link.phtml';

    // Variables 

<!-- Components/view/frontend/Components/Basic/Link.phtml -->
<a href=" echo $url;