{"id":47,"date":"2011-06-27T07:46:44","date_gmt":"2011-06-27T07:46:44","guid":{"rendered":"http:\/\/beta.robertprice.co.uk\/robblog\/2011\/06\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/"},"modified":"2011-06-27T07:46:44","modified_gmt":"2011-06-27T07:46:44","slug":"access_the_bootstrap_from_a_zend_framework_action_controller-shtml","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/","title":{"rendered":"Access The Bootstrap From A Zend Framework Action Controller"},"content":{"rendered":"<p>\nWhen working with the Zend Framework you often need access to the Bootstrap to fetch resources. The classic way to get the bootstrap in most of the examples for the Zend Framework is like this&#8230;\n<\/p>\n<div class=\"code\"><code>$bootstrap = $this-&gt;getBootstrap();<br \/>\n<\/code><\/div>\n<p>\nHowever, this method is not globally available, so from an action controller for example, that method would fail. There is an alternative way to get access to the Bootstrap.\n<\/p>\n<div class=\"code\"><code>$bootstrap = $this-&gt;getInvokeArg('bootstrap');<br \/>\n<\/code><\/div>\n<p>\nThis works because Zend_Application_Bootstrap_Bootstrap registers itself as the front controller parameter <var>bootstrap<\/var>, which lets us access it from the router, dispatcher, plugins and action controllers.\n<\/p>\n<p>\nSo, if I had a twig resource I wanted to access from an action controller, I could use the following code&#8230;\n<\/p>\n<div class=\"code\"><code>$bootstrap = $this-&gt;getInvokeArg('bootstrap');<br \/>\n$twig = $bootstrap->getResource('twig');<br \/>\n<\/code><\/div>\n<p>\nor by chaining accessors, I could reduce this to one line&#8230;\n<\/p>\n<div class=\"code\"><code>$twig = $this-&gt;getInvokeArg('bootstrap')->getResource('twig');<br \/>\n<\/code><\/div>\n<p>\nFor more information, read <a href=\"http:\/\/framework.zend.com\/manual\/en\/zend.application.theory-of-operation.html\">Zend Framework&#8217;s Theory of Operation<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with the Zend Framework you often need access to the Bootstrap to fetch resources. The classic way to get the bootstrap in most of the examples for the Zend Framework is like this&#8230; $bootstrap = $this-&gt;getBootstrap(); However, this method is not globally available, so from an action controller for example, that method would &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Access The Bootstrap From A Zend Framework Action Controller&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[75],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-dev","tag-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Access The Bootstrap From A Zend Framework Action Controller - Robert Price<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Access The Bootstrap From A Zend Framework Action Controller - Robert Price\" \/>\n<meta property=\"og:description\" content=\"When working with the Zend Framework you often need access to the Bootstrap to fetch resources. The classic way to get the bootstrap in most of the examples for the Zend Framework is like this&#8230; $bootstrap = $this-&gt;getBootstrap(); However, this method is not globally available, so from an action controller for example, that method would &hellip; Continue reading &quot;Access The Bootstrap From A Zend Framework Action Controller&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-27T07:46:44+00:00\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"Access The Bootstrap From A Zend Framework Action Controller\",\"datePublished\":\"2011-06-27T07:46:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/\"},\"wordCount\":143,\"keywords\":[\"Web Development\"],\"articleSection\":[\"Dev\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/\",\"name\":\"Access The Bootstrap From A Zend Framework Action Controller - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"datePublished\":\"2011-06-27T07:46:44+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Access The Bootstrap From A Zend Framework Action Controller\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Access The Bootstrap From A Zend Framework Action Controller - Robert Price","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/","og_locale":"en_GB","og_type":"article","og_title":"Access The Bootstrap From A Zend Framework Action Controller - Robert Price","og_description":"When working with the Zend Framework you often need access to the Bootstrap to fetch resources. The classic way to get the bootstrap in most of the examples for the Zend Framework is like this&#8230; $bootstrap = $this-&gt;getBootstrap(); However, this method is not globally available, so from an action controller for example, that method would &hellip; Continue reading \"Access The Bootstrap From A Zend Framework Action Controller\"","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/","og_site_name":"Robert Price","article_published_time":"2011-06-27T07:46:44+00:00","author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"Access The Bootstrap From A Zend Framework Action Controller","datePublished":"2011-06-27T07:46:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/"},"wordCount":143,"keywords":["Web Development"],"articleSection":["Dev"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/","name":"Access The Bootstrap From A Zend Framework Action Controller - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"datePublished":"2011-06-27T07:46:44+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/access_the_bootstrap_from_a_zend_framework_action_controller-shtml\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"Access The Bootstrap From A Zend Framework Action Controller"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":0,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}