Generating table schema from entities - symfony

I am using Skipper ORM to design/generate entities - everything exports fine - then I do:
app/console doctrine:database:drop --force
app/console doctrine:database:create
app/console doctrine:schema:update --force
app/console doctrine:generate:entities --no-backup MyNamespace/MyBundle
I am receiving an error/exception:
[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'alternateId' on table 'inventory'.
What gives? The entity in question certainly does have the field:
<?php
namespace Company\DistributionBundle\Entity;
use Doctrine\ORM\Mapping AS ORM;
/**
* #ORM\Entity(repositoryClass="Company\DistributionBundle\Repository\InventoryRepository")
* #ORM\Table(
* name="inventory",
* indexes={#ORM\Index(name="ALTID", columns={"alternateId"})},
* uniqueConstraints={
* #ORM\UniqueConstraint(name="PKID", columns={"id"}),
* #ORM\UniqueConstraint(name="FINDID", columns={"partNumber","partDescription"})
* }
* )
*/
class Inventory
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(type="integer", nullable=false)
*/
private $alternateId;
/**
* #ORM\Column(type="integer", nullable=false)
*/
private $unitOftMeasure;
/**
* #ORM\Column(type="integer", nullable=false)
*/
private $minimumQuantity;
/**
* #ORM\Column(type="integer", nullable=false)
*/
private $maximumQuantity;
/**
* #ORM\Column(type="decimal", nullable=false)
*/
private $maximumCycles;
/**
* #ORM\Column(type="decimal", nullable=false, precision=10, scale=4)
*/
private $maximumTime;
/**
* #ORM\Column(type="decimal", nullable=false, precision=10, scale=2)
*/
private $listPrice;
/**
* #ORM\Column(type="date", nullable=false)
*/
private $datePrice;
/**
* #ORM\Column(type="string", length=50, nullable=false)
*/
private $partNumber;
/**
* #ORM\Column(type="string", length=50, nullable=false)
*/
private $partDescription;
/**
* #ORM\Column(type="text", length=255, nullable=true)
*/
private $partNotes;
/**
* #ORM\OneToOne(targetEntity="Company\DistributionBundle\Entity\Application", inversedBy="inventory")
* #ORM\JoinColumn(name="application_id", referencedColumnName="id", nullable=false, unique=true)
*/
private $application;
/**
* #ORM\OneToOne(targetEntity="Company\DistributionBundle\Entity\Category", inversedBy="inventory")
* #ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=false, unique=true)
*/
private $category;
/**
* #ORM\OneToOne(targetEntity="Company\DistributionBundle\Entity\Manufacturer", inversedBy="inventory")
* #ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id", nullable=false, unique=true)
*/
private $manufacturer;
/**
* #ORM\ManyToMany(targetEntity="Company\DistributionBundle\Entity\InventoryOptions", mappedBy="inventory")
*/
private $inventoryOptions;
}

Try using the doctrine migrations bundle for two reasons:
It helps you manage your production database and all the versions of it. You can check any version any time
It Beautifully creates 'sql migrations' for you. Which you can use to (run migrations) to make changes in database.
Also, it understand your entities, read the annotations and creates the required files.
Go ahead and explore it.

Related

Symfony3 - The association refers to the owning side field which does not exist with ManyToMany and fields table

i'm trying to make a manyToMany relationship with more attributes than the ids, so I need two OneToMany relationships and two ManytoOne relationships having three tables/entities.
I have Product entity, Client entity and ProductClient entity:
class Client
{
/**
* #var integer
*
* #ORM\Column(name="id_client", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idClient;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=100, nullable=false)
*/
private $name;
/**
* #var \ProductClient
*
* #ORM\OneToMany(targetEntity="ProductClient", mappedBy="client")
*/
private $products_clients;
}
class Product
{
/**
* #var integer
*
* #ORM\Column(name="id_product", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idProduct;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=100, nullable=false)
*/
private $name;
/**
* #var \ProductClient
*
* #ORM\OneToMany(targetEntity="ProductClient", mappedBy="product")
*/
private $products_clients;
}
class ProductClient
{
/**
* #ORM\Column(name="product_id", type="integer")
* #ORM\Id
* #ORM\ManyToOne(targetEntity="Product", inversedBy="products_clients")
* #ORM\JoinColumn(name="product_id", referencedColumnName="id_product", nullable=false)
*/
protected $product;
/**
* #ORM\Column(name="client_id", type="integer")
* #ORM\Id
* #ORM\ManyToOne(targetEntity="Client", inversedBy="products_clients")
* #ORM\JoinColumn(name="client_id", referencedColumnName="id_client", nullable=false)
*/
protected $client;
/**
* #var bool
*
* #ORM\Column(name="status", type="boolean")
*/
private $status;
}
That's something like this (with its getters and setters and more attributes). But symfony launches two "invalid entities errors" when I go to the Product crud:
AppBundle\Entity\Product - The association AppBundle\Entity\Product#products_clients refers to the owning side field AppBundle\Entity\ProductClient#product which is not defined as association, but as field.
AppBundle\Entity\Product - The association AppBundle\Entity\Product#products_clients refers to the owning side field AppBundle\Entity\ProductClient#product which does not exist.
And the same result if I go to the Client crud. What's wrong?
As you can see in the error message, AppBundle\Entity\ProductClient#product is not defined as association, but as field.
Just remove this #ORM\Column(name="product_id", type="integer") and this #ORM\Column(name="client_id", type="integer").
class ProductClient
{
/**
* #ORM\Id
* #ORM\ManyToOne(targetEntity="Product", inversedBy="products_clients")
* #ORM\JoinColumn(name="product_id", referencedColumnName="id_product", nullable=false)
*/
protected $product;
/**
* #ORM\Id
* #ORM\ManyToOne(targetEntity="Client", inversedBy="products_clients")
* #ORM\JoinColumn(name="client_id", referencedColumnName="id_client", nullable=false)
*/
protected $client;
/**
* #var bool
*
* #ORM\Column(name="status", type="boolean")
*/
private $status;
}

Symfony save date for every change status

how i can to do this: I have OrderWork entity this for order and have relation manyToMany with Status entity. All work good, but i want have date for every saved and updated order.
* Order
*
* #ORM\Table(name="order_work")
* #ORM\Entity(repositoryClass="AppBundle\Repository\OrderWorkRepository")
*/
class OrderWork
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="Client", cascade={"persist"})
* #ORM\JoinColumn(name="client_id", referencedColumnName="id")
*/
private $client;
/**
* #var string
*
* #ORM\Column(name="orderNumber", type="string", length=255)
*/
private $orderNumber;
/**
* #var string
*
* #ORM\Column(name="orderCity", type="string", length=255)
*/
private $orderCity;
/**
* #var date
*
* #ORM\Column(name="date", type="string", length=255)
*/
private $date;
/**
* #var \DateTime
*
* #ORM\Column(name="orderDate", type="string", length=255, options={"default": NULL})
*/
private $orderDate;
/**
* #var \DateTime
*
* #ORM\Column(name="returnDate", type="string", length=255, nullable=true)
*/
private $returnDate;
/**
* #var string
*
* #ORM\Column(name="device", type="string", length=255)
*/
private $device;
/**
* #ORM\ManyToOne(targetEntity="SurrogatePhone", cascade={"persist"})
* #ORM\JoinColumn(name="surrogate_id", referencedColumnName="id")
*/
private $surrogatePhone;
/**
* #var int
*
* #ORM\Column(name="orderType", type="integer")
*/
public $orderType;
/**
* #ORM\ManyToMany(targetEntity="Status")
* #ORM\JoinTable(name="order_status",
* joinColumns={#ORM\JoinColumn(name="order_id", referencedColumnName="id", unique=false)},
* inverseJoinColumns={#ORM\JoinColumn(name="status_id", referencedColumnName="id", unique=false)}
* )
*/
private $status;
How better resolve this solution?
Define date in your constructor (for creating):
class OrderWork
{
//...
public function __construct()
{
$this->date = new DateTime();
}
}
And update date field when updating:
$orderWork->setDate(new DateTime());
$em->flush();

symfony doctrine multiple relations

I'm quite new to Symfony and Doctrine so....
In my application i have the following entities:
class Company
/**
* #ORM\Id()
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #ORM\Column(name="name", type="string", length=255)
* #ORM\OneToMany(targetEntity="\UserBundle\Entity\User", mappedBy="company")
* #ORM\OneToMany(targetEntity="\AppBundle\Entity\Account", mappedBy="company")
*/
protected $name;
public function __construct()
{
$this->name = new ArrayCollection();
}
UserClass (FOSUserBundle):
class User extends BaseUser
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="firstname", type="string", length=255)
*/
protected $firstname;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255)
*/
protected $name;
/**
* #ORM\ManyToOne(targetEntity="\AppBundle\Entity\Company")
* #ORM\JoinColumn(name="company_id", referencedColumnName="id")
*/
protected $company;
and Accounts:
class Account
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="num", type="integer")
*/
private $num;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* #ORM\ManyToOne(targetEntity="\AppBundle\Entity\Company")
* #ORM\JoinColumn(name="company_id", referencedColumnName="id")
*/
protected $company;
There are the following relations.
one company --> many users, many users --> one company;
one company --> many accounts; many accounts --> one company;
is it possible to generate the relations as i did by:
* #ORM\Column(name="name", type="string", length=255)
* #ORM\OneToMany(targetEntity="\UserBundle\Entity\User", mappedBy="company")
* #ORM\OneToMany(targetEntity="\AppBundle\Entity\Account", mappedBy="company")
--> two target entities?
thx for your help...
This is absolutely wrong. If you don't want any links from company to users and accounts then you can just omit this fields. And this relation will be unidirectional. You will have link to Company from both User and Account.
Just omit wrong mappings:
/**
* #ORM\Column(name="name", type="string", length=255)
*/
protected $name;
If you want to create link to users and accounts related to company you need to define fields for these ArrayCollections like that:
/**
* #ORM\OneToMany(targetEntity="\UserBundle\Entity\User", mappedBy="company")
*/
protected $users;

Sonata Admin Custom field with data transformer

I have a easy form with a data transformer, it works correctly (update, persist and delete) but I get a error on twig.
Impossible to invoke a method ("trans") on a NULL variable ("") in SonataDoctrineORMAdminBundle:CRUD:edit_orm_one_to_many.html.twig at line 30
error is in this line:
{{ nested_field.vars['sonata_admin'].admin.trans(nested_field.vars.label) }}
All fields have value in nested_field.vars['sonata_admin'] less my custom field
My code is this:
$formMapper
->add(
$formMapper->create('articleAmount', 'text')
->addModelTransformer($articleAmountToStringTransformer)
)
...
Entities
/**
* AppShopHasArticles
*
* #ORM\Table(name="app_shop_has_articles")
* #ExclusionPolicy("all")
* #ORM\Entity(repositoryClass="Nvia\ShopAppBundle\Entity\Repository\AppShopHasArticlesRepository")
* #ORM\HasLifecycleCallbacks()
*/
class AppShopHasArticles
{
/**
* #var \Nvia\CommonBundle\Entity\Article
*
* #ORM\ManyToOne(targetEntity="Nvia\ShopAppBundle\Entity\Article", inversedBy="appShopHasArticles")
* #ORM\JoinColumn(name="article_id", referencedColumnName="id", nullable=false)
* #ORM\Id
* #Expose
*/
private $article;
/**
* #var \Nvia\CommonBundle\Entity\Country
*
* #ORM\ManyToOne(targetEntity="Nvia\CommonBundle\Entity\Country")
* #ORM\JoinColumn(name="country_id", referencedColumnName="id", nullable=false)
* #ORM\Id
* #Expose
*/
private $country;
/**
* #var \Nvia\ShopAppBundle\Entity\AppShop
*
* #ORM\ManyToOne(targetEntity="Nvia\ShopAppBundle\Entity\ArticleAmount")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="country_id", referencedColumnName="country_id", nullable=false),
* #ORM\JoinColumn(name="article_id", referencedColumnName="article_id", nullable=false)
* })
* #Expose
*/
private $articleAmount;
...
}
/**
* ArticleAmount
*
* #ORM\Table(name="article_amount")
*/
class ArticleAmount
{
/**
* #var \Nvia\CommonBundle\Entity\Article
*
* #ORM\ManyToOne(targetEntity="Nvia\ShopAppBundle\Entity\Article", inversedBy="articleAmounts")
* #ORM\JoinColumn(name="article_id", referencedColumnName="id", nullable=false)
* #ORM\Id
*/
private $article;
/**
* #var \Nvia\CommonBundle\Entity\Country
*
* #ORM\ManyToOne(targetEntity="Nvia\CommonBundle\Entity\Country")
* #ORM\JoinColumn(name="country_id", referencedColumnName="id", nullable=false)
* #ORM\Id
*/
private $country;
/**
* #var float
*
* #ORM\Column(name="amount", type="float", precision=10, scale=0, nullable=false)
* #Expose
*/
private $amount;
/**
* #var \DateTime
*
* #ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;
}
What am I doing wrong :/ ?
When using the create method of the formMapper sonata will not insert it's own logic.
Instead try something like this
$formMapper
->add('articleAmount', 'text')
->get('articleAmount')
->addModelTransformer($articleAmountToStringTransformer)
Tested on Sonata 2.4

Symfony 20 Minute Page Load Times

Does anyone have a clue why in the world I would be getting 20 minute page load times in dev in Symfony2? It just randomly happens to me. One day I will get fast load times, the next day I am twiddling my thumbs waiting for a page to load. What can I check/disable/enable/etc? Thanks!
Here is my latest page load:
Time: 298068 ms
Here is the Entity for PurchaseOrder
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="archived_po_number", type="string", length=50, nullable=true)
* #Common\Versioned
*/
private $archived_po_number;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=50, nullable=true)
* #Common\Versioned
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="show_locations", type="string", length=1, nullable=true)
* #Common\Versioned
*/
private $show_locations;
/**
* #var integer
*
* #ORM\Column(name="freight", type="decimal", precision=10, scale=2, nullable=true)
* #Common\Versioned
*/
private $freight;
/**
* #var integer
*
* #ORM\Column(name="pallets", type="integer", nullable=true)
* #Common\Versioned
*/
private $pallets;
/**
* #var integer
*
* #ORM\Column(name="boxes", type="integer", nullable=true)
* #Common\Versioned
*/
private $boxes;
/**
* #var text
* #ORM\Column(name="internal_notes", type="text", nullable=true)
* #Common\Versioned
*/
private $internal_notes;
/**
* #var text
* #ORM\Column(name="sales_rep_notes", type="text", nullable=true)
* #Common\Versioned
*/
private $sales_rep_notes;
/**
* #var string
*
* #ORM\Column(name="custom_purchase_order_number", type="string", length=255, nullable=true)
* #Common\Versioned
*/
private $custom_purchase_order_number;
/**
* #ORM\ManyToOne(targetEntity="WIC\CommonBundle\Entity\CustomOptions", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="purchase_order_class", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $purchase_order_class;
/**
* #ORM\ManyToOne(targetEntity="WIC\WarehouseBundle\Entity\Warehouse", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="generated_by_location", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $generated_by_location;
/**
* #ORM\ManyToOne(targetEntity="WIC\InventoryLocationBundle\Entity\InventoryLocation", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="receive_location", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $receive_location;
/**
* #ORM\ManyToOne(targetEntity="WIC\WarehouseBundle\Entity\Warehouse", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="company_name", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $company_name;
/**
* #ORM\ManyToOne(targetEntity="WIC\WarehouseBundle\Entity\Warehouse", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="ship_to", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $ship_to;
/**
* #ORM\ManyToOne(targetEntity="WIC\WarehouseBundle\Entity\Warehouse", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="bill_to", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $bill_to;
/**
* #ORM\ManyToOne(targetEntity="WIC\CommonBundle\Entity\CustomOptions", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="payment_terms", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $payment_terms;
/**
* #ORM\ManyToOne(targetEntity="WIC\CommonBundle\Entity\CustomOptions", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="fob", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $fob;
/**
* #ORM\ManyToOne(targetEntity="WIC\CommonBundle\Entity\CustomOptions", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="ship_via", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $ship_via;
/**
* #var datetime
*
* #ORM\Column(name="ship_by", type="datetime", nullable=true)
* #Common\Versioned
*/
private $ship_by;
/**
* #var datetime
*
* #ORM\Column(name="cancel_by", type="datetime", nullable=true)
* #Common\Versioned
*/
private $cancel_by;
/**
* #var datetime
*
* #ORM\Column(name="due_by", type="datetime", nullable=true)
* #Common\Versioned
*/
private $due_by;
/**
* #var string
*
* #ORM\Column(name="nbt", type="string", length=2, nullable=true)
* #Common\Versioned
*/
private $nbt;
/**
* #ORM\OneToMany(targetEntity="WIC\PurchaseOrderLineItemBundle\Entity\PurchaseOrderLineItem", mappedBy="purchaseOrder", cascade={"remove"}, fetch="EAGER")
*/
protected $purchaseOrderLineItem;
/**
* #ORM\OneToMany(targetEntity="WIC\PurchaseOrderBundle\Entity\PurchaseOrderCharge", mappedBy="purchaseOrder", cascade={"remove"}, fetch="EAGER")
*/
protected $purchaseOrderCharge;
/**
* #ORM\OneToMany(targetEntity="WIC\PurchaseOrderBundle\Entity\PurchaseOrderPayment", mappedBy="purchaseOrder", cascade={"remove"}, fetch="EAGER")
*/
protected $purchaseOrderPayment;
/**
* #ORM\ManyToOne(targetEntity="WIC\SupplierBundle\Entity\Supplier", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="supplier_id", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
protected $supplier;
/**
* #ORM\ManyToOne(targetEntity="WIC\CommonBundle\Entity\CustomOptions", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="status_id", referencedColumnName="id", nullable=true)
* #Common\Versioned
*/
private $status;
/**
* #ORM\ManyToOne(targetEntity="WIC\UserBundle\Entity\User")
* #ORM\JoinColumn(name="created_by", referencedColumnName="id")
* #Common\Blameable(on="create")
*/
private $createdBy;
/**
* #ORM\ManyToOne(targetEntity="WIC\UserBundle\Entity\User")
* #ORM\JoinColumn(name="updated_by", referencedColumnName="id")
* #Common\Blameable(on="update")
*/
private $updatedBy;
/**
* #ORM\ManyToOne(targetEntity="WIC\AccountBundle\Entity\Account", inversedBy="purchaseOrders")
* #ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false)
* #Common\Versioned
* #Common\Blameable(on="create")
*/
protected $account;
/**
* #var datetime $created
*
* #Common\Timestampable(on="create")
* #ORM\Column(type="datetime")
*/
private $created;
/**
* #var datetime $updated
*
* #Common\Timestampable(on="update")
* #ORM\Column(type="datetime", nullable=true)
*/
private $updated;
/**
* #ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
Here is my controller method listAction()
// verify access
if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) {
$classIdentity = new ObjectIdentity('class', 'WIC\\PurchaseOrderBundle\\Entity\\PurchaseOrder');
if (false === $this->get('security.context')->isGranted('VIEW', $classIdentity)) {
throw new AccessDeniedException('Only an admin user has access to this section...');
}
}
// get user's account
$account = $this->getUser()->getAccount();
$search_form = $this->createForm(new PurchaseOrderSearchType());
$em = $this->getDoctrine()->getManager();
if ($request->isMethod('POST')) {
$search_form->bind($request);
// if ($search_form->isValid()) {
$data = $search_form->getData();
$purchaseOrders = $em->getRepository('WICPurchaseOrderBundle:PurchaseOrder')->getListBy($data);
// }
} else {
if($this->get('request')->query->get('letter')){
}else{
}
// Set the up the pagination statement...
$em = $this->getDoctrine()->getManager();
$dql = "SELECT p FROM WIC\PurchaseOrderBundle\Entity\PurchaseOrder p WHERE p.account=:account_id ORDER BY p.created desc";
$query = $em->createQuery($dql);
$query->setParameters(array(
'account_id' => $account->getId(),
));
$paginator = $this->get('knp_paginator');
$paginatorObject = $paginator->paginate(
$query,
$this->get('request')->query->get('page', 1),25
);
// $purchaseOrders = $em->getRepository('WICPurchaseOrderBundle:PurchaseOrder')->findByAccount($account->getId(),array('id' => 'DESC'));
}
return array(
'heading' => 'Purchase Order',
'sidebarLeftTitle'=>'Purchase Order Menu',
'purchaseOrders' => $paginatorObject,
'search_form' => $search_form->createView(),
);
By default in app_dev.php you have the profiler bar, click on the timer and you will have a good start to debug (timeline with main/sub request, etc)
The issue was in the OneToMany relationship code where it says fetch="EAGER". This was pulling in all sorts of unnecessary associations and db queries. When I removed it, the db queries went down to 4 per page instead of 4000.
Are you using x-debug or any PHP level profiling? You've either got some form of recursion happening or one of the steps in the security\http\firewall process is taking a very long time to complete.
My suggestion would be
Look at your stack-trace and find anywhere there are highly repeated events around the security\http\firewall code and investigate if they exist
Quickly step through your code using x-debug, and find where the delay is occurring. With a few page reloads you should be able to step into the section which is causing the long page load times.
If you are using profiling, make sure your created files aren't ridiculously verbose. I've seen this long page load issue happen before due to profiling, where each page load would create a 20Gb+ profiling file.

Resources