PhotonBundle for Symfony

in #utopian-io7 years ago (edited)

Photon for Symfony

Photon is an image acceleration and modification service for Jetpack-connected WordPress sites.

To use in symfony, PhotonBundle uses Photon Wrapper

compatibility Symfony 3.x, 4.x

Installation

composer require bencagri/photon-bundle

Then register the bundle in app/AppKernel.php

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ....
            //Photon Bundle
            new \Bencagri\PhotonBundle\PhotonBundle(),
        ];

Thats it.

Usage

There is a service that you can use in Symfony.

in your controller;

use Photon\Wrapper\Effect\Filter;
use Photon\Wrapper\Effect\Width;
use Photon\Wrapper\Effects;

...

public function indexAction(Request $request)
{
    //get the service
    $generator = $this->get('bencagri.photon.service');

    //register the effects that you want to use
    $effects = new Effects(
        new Width(700),
        new Filter('emboss')
    );

    $imageUrl = 'https://images.com/my.jpg';
    
    //generate the picture
    $generator->generate($imageUrl,$effects);
}

See all effects that you can use on Photon Wrapper examples.

Contribute

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Licence

  • The Photon Bundle is open-sourced software licensed under the MIT license.
  • The Photon Wrapper is open-sourced software licensed under the MIT license.
  • The Photon is open-sourced software licenced under GNU GENERAL PUBLIC LICENCE



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it is too small of a contribution. What you are doing is just one line to generate the Image with the effects provided.

$generator = new Generate($imageUrl, $effects);

Also most of the code is added as a single commit which is not in line with the rule which states

Contributions must have a comprehensible commit history. Larger projects or updates submitted in a single commit will not be accepted.

You can contact us on Discord.
[utopian-moderator]

-"What you are doing is just one line to generate the Image with the effects provided"
This is for Symfony integration of Photon-Wrapper. So, photon-wrapper does the job.

-"Also most of the code is added as a single commit which is not in line with the rule which states."
For a bundle, (if its not a huge one) you shouldnt commit each file seperately. Write the code test it and push. Its a simple job. Next commits should be for the features or bug fixes.

I understand that, we shouldnt create packages for Symfony, Laravel or any other frameworks.

anyway, thanks for the comment.

Have a nice day.

edit. Btw, where is $generator = new Generate($imageUrl, $effects); ? Cause I didnt use such an implementation above? =)

I have checked the repo and it is https://github.com/bencagri/photon-bundle/blob/master/src/Service/PhotonService.php where the code is there $generator = new Generate($imageUrl, $effects);.

True, wrappers' generator. And yes, Its generating the provided effects with one line code.

Should I create a bundle from scratch, not to use one line code?

Its not that you cannot use one line of code, but creating a contribution for that one line is not welcomed in Utopian.io.

But its a package. Do you want me to fake it with more lines of code? If so, let me do it.

Edit:
Like this? https://github.com/bencagri/photon-bundle/blob/master/src/Service/PhotonService.php#L22

Sorry friend, Im still trying to understand the criterias of the rules.

I am not saying that you should fake it to get more lines of code, what I am trying to say is that most of the work is done by the package and I cannot see what you have done.

Ohh, Let me answer this question.

Im using symfony mostly. In one of my projects, Image Manipulation was needed. So i wanted to create something for this.

Then I said, ok, first create a wrapper for this, maybe some others may need to use it. So i created the photon wrapper.

Back to our case, I need a bundle to use it in symfony. Cause Im also using some other components and packages (a lot).

For example In this case, I will use monolog with this service to log non-accesseble images. So, I need symfony's dependency injection. Creating a service and overriding it would be solution for me.

Maybe some other developers (for symfony) need this bundle. So that, I also put this.

Conclusion,
This is a Symfony Bundle. For only symfony framework. Some can implement it for Laravel or any other framework. Wrapper is standalone package.

I hope I am clear now.

Back to my first comment I said,I understand that, we shouldnt create packages for Symfony, Laravel or any other frameworks. And your reply (I cannot see what you have done.) supports this. Am I correct?