1. Go to this page and download the library: Download appsco/pan-crop-bundle 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/ */
appsco / pan-crop-bundle example snippets
php
namespace AcmeBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class ProfileType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
// PROFILE
$builder
->add('email', 'email')
->add('picture_blob', 'pan_crop', array(
' /**
* Returns the name of this type.
* @return string The name of this type
*/
public function getName()
{
return 'profile';
}
}
php
namespace AcmeBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
public function indexAction($userId, Request $request)
{
$user = $this->loadUser($userId);
$form = $this->createForm('profile', $user);
$form->handleRequest($request);
if ($form->isValid()) {
if ($blob = $user->getPicture()) {
if ($blob->getContent()) {
$this->savePicture($blob);
}
if ($blob->getId()) {
$user->setPictureUrl(
$this->router->generate(
'picture_path',
array('blobId' => $blob->getId()),
UrlGeneratorInterface::ABSOLUTE_URL
)
);
}
}
$this->saveUser($user);
}
return $this->render('@Acme/Default/index.html.twig', array(
'user' => $user,
'form' => $form->createView(),
));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.