Webiny Framework Modern and fast PHP framework

Developed as a foundation for Webiny Platform - the new age CMS, but you can use it for any of your projects.

  1. Open source
  2. Composer ready
  3. 22 components

Some code examples


Image

Image manipulation library.

class MyClass
{
    // use the ImageTrait
    use \Webiny\Component\Image\ImageTrait;

    function index()
    {
        // $image from Storage component
        $imgInstance = $this->image($image);

        // manipulate the image
        $imgInstance->resize(800, 800)
            ->crop(200, 200, 50, 40)
            ->rotate(30, 'bfbfbf');

        // output the new image
        $imgInstance->show();
    }
}

  Visit the Image component page

Entity

Our own MongoDb ODM.

// load comments for a specific page
$page = Page::findById("53712ed46803fa4e058b456b");

// output the number of comments for the current page
// comments are automatically loaded over a reference
echo $page->comments->count();

// $comment is also an Entity instance with implemented ArrayAccess
foreach($page->comments as $comment){
    // get author's nickname (over another reference)
    $authorNickname = $comment->author->nickName;

    // get entire Author entity
    $authorEntity = $comment->author;

    // count all comments posted by this comment's author
    $authorCommentsCount = $comment->author->comments->count();
}
    

  Visit the Entity component page

Cache

Supports Apc(u), Redis, Memcache, Couchbase.

class MyClass
{
    // use the CacheTrait
    use \Webiny\Component\Cache\CacheTrait;

    public function index()
    {
        // get cache service and save a new cache key
        $this->cache('Frontend')->save('cache_key', 'value', 500);

        // cache read example
        $value = $this->cache('Frontend')->read('cache_key');

        // delete from cache
        $cache->delete('cache_key');
    }
}

  Visit the Cache component page

Storage

A component for file storage, supports local storage and Amazon S3.

class MyClass
{
    // use StorageTrait
    use \Webiny\Component\Storage\StorageTrait;

    public function index()
    {
       // get your storage service
        $storage = $this->storage('local');

        // create a file object
        $file = new LocalFile('file.txt', $storage);

        // set file content
        $file->setContents('foo');
    }
}

  Visit the Storage component page

Router

The router component is used for mapping defined paths/urls to appropriate controllers or services.

class MyClass
{
    // use the RouterTrait
    use \Webiny\Component\Router\RouterTrait;

    function index()
    {
        // match route defined route
        $result = $this->router()->match('blog/tag/some_tag');

        // if route is matched, execute the callback
        if($result){
            $callbackResult = $this->router()->execute($result);
        }
    }
}

  View the Router component page

Security

Provides authentication and authorization mechanisms. Authentication supports Http, Form, OAuth2 and TwitterOAuth providers.

class MyClass
{
    // use the SecurityTrait
    use \Webiny\Component\Security\SecurityTrait;

    function index()
    {
        // get authenticated user
        $user = $this->security()->firewall('admin')->getUser();

        // check if user has a role
        if($user->hasRole('ROLE_EDITOR')) {
            // user has the defined or any higher role
        }
    }
}

  View the Security component page

Explore Webiny Framework components:

  • Amazon currently supports implementation of Amazon S3
  • Annotations component for parsing annotations from a class, method or a property
  • Cache provides several caching libraries like Apc, Couchbase, Memcache and Redis
  • ClassLoader a PSR-0, PSR-4 and PEAR class loader
  • Config a very handy library for parsing YAML, INI, JSON and PHP configuration files
  • Crypt library for encoding, decoding and validating hashes
  • Entity an ODM layer (currently only supports MongoDB)
  • EventManager want to do event-based development, this is a library for you
  • Http library for parsing HTTP requests and creating HTTP responses
  • Image library for image manipulation
  • Logger PSR-3 log components for logging code execution in runtime
  • Mailer component for sending emails
  • Mongo MongoDB class wrapper
  • OAuth2 library for working with OAuth2, currently supports Facebook, LinkedIn and Google+
  • REST fully featured REST library with caching, security and rate control
  • Router handles defining, parsing, creating and matching url routes
  • Security provides authorization and authentication layer
  • ServiceManager want to write truly service based, loosely-coupled code, this library provides that
  • StdLib this component provides object wrappers for Arrays, Strings, Urls and DateTime data types
  • Storage storage abstraction layer that simplifies the way you work with files and directories
  • TemplateEngine provides a layer for rendering view templates and defining template plugins and manipulators
  • TwitterOAuth library for working with Twitter API using Twitter OAuth

SIGN UP FOR EARLY BETA ACCESS:

Lastest from our blog:

The Power of the Community

In the focus of recent feedback that I got, I think there is a need for me to justify some of the decisions we made while developing Webiny Framework.

Share & subscribe: