Skip to content

Instantly share code, notes, and snippets.

@rei999
rei999 / symfony_cheatsheet_2.6
Last active August 29, 2015 14:17
Cheat Sheet for Symfony 2.6
Create a new project:
symfony new {{project_name}}
php app/console generate:bundle --namespace=Acme/DemoBundle --format=yml
Help:
php app/console config:dump-reference FrameworkBundle
Doctrine:
php app/console doctrine:database:create
php app/console doctrine:generate:entities TwoSixRandomBundle:Product
@rei999
rei999 / sns.php
Created March 26, 2015 01:43
Kenneth Sample Code - Task to send queued messages to Amazon SNS
<?php
namespace MoonLight\MainBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use MoonLight\MainBundle\Entity\Push;
use Aml\UserBundle\Entity\User;
use Aws\Sns\SnsClient;
@rei999
rei999 / transaction.php
Created March 26, 2015 01:25
Kenneth Sample Code - Upgrade to premium membership with Stripe
<?php
namespace MoonLight\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\View\View;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Aml\UserBundle\Entity\User;
use MoonLight\MainBundle\Entity\Transaction;
use MoonLight\MainBundle\Entity\FailedTransaction;
use MoonLight\MainBundle\Entity\Membership;
use MoonLight\MainBundle\Repository\TransactionRepository;
@rei999
rei999 / cxfservlet_jaxrs_upload.xml
Created November 18, 2013 19:10
cxfservlet_jaxrs_upload.xml
<jaxrs:server address="/api">
<jaxrs:properties>
<entry key="org.apache.cxf.propogate.exception" value="false"/>
<entry key="attachment-directory" value="/mnt/wundr_temp"/>
<entry key="attachment-memory-threshold" value="404800"/>
<entry key="attachment-max-size" value="1073741824"/>
</jaxrs:properties>
</jaxrs:server>
@rei999
rei999 / async_service.java
Created November 4, 2013 22:54
AsyncService Example
public interface MyService {
Future<String> testAsync();
}
@Service
@Transactional
public class MyServiceImpl implements MyService {
@Async
@Override
public Future<String> testAsync() {
@rei999
rei999 / bean_async.xml
Created November 4, 2013 22:43
Enable task annotation
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
default-lazy-init="true">
<!-- async support -->
@rei999
rei999 / servlet_3_xmlns.xml
Created November 4, 2013 22:38
Serlvet 3.0 Async Web.xml Namespace
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>
@rei999
rei999 / enable_async.xml
Created November 4, 2013 22:34
async support in web.xml
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<async-supported>true</async-supported>
@rei999
rei999 / spring_maven.xml
Created November 4, 2013 22:31
Spring Maven Install 3.2.4
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
</dependencies>
package com.developer24hours.elasticsearch.service;
public interface ElasticSearchService {
public boolean indexCategories();
}