3:I[5613,[],""] 4:I[1778,[],""] 5:I[2266,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","787","static/chunks/787-34619535dc4c8b8e.js","185","static/chunks/app/layout-09adbc10fe12bbc4.js"],"Providers"] 6:I[4676,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","787","static/chunks/787-34619535dc4c8b8e.js","185","static/chunks/app/layout-09adbc10fe12bbc4.js"],"Layout"] 7:I[5250,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","802","static/chunks/app/docs/controller/page-810a2a590952fdc2.js"],""] 0:["BUBEAAcODzJ5deDZjftgQ",[[["",{"children":["docs",{"children":["controller",{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],["",{"children":["docs",{"children":["controller",{"children":["__PAGE__",{},["$L1","$L2",null]]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children","controller","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","className":"h-full antialiased __variable_aaf875 __variable_b436a8","suppressHydrationWarning":true,"children":["$","body",null,{"className":"flex min-h-full bg-white dark:bg-slate-900","children":["$","$L5",null,{"children":["$","$L6",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":["$","div",null,{"className":"min-w-0 max-w-2xl flex-auto px-4 py-16 lg:max-w-none lg:pl-8 lg:pr-0 xl:px-16","children":["$","div",null,{"className":"flex h-full flex-col items-center justify-center text-center","children":[["$","p",null,{"className":"font-display text-sm font-medium text-slate-900 dark:text-white","children":"404"}],["$","h1",null,{"className":"mt-3 font-display text-3xl tracking-tight text-slate-900 dark:text-white","children":"Page not found"}],["$","p",null,{"className":"mt-2 text-sm text-slate-500 dark:text-slate-400","children":"Sorry, we couldn’t find the page you’re looking for."}],["$","$L7",null,{"href":"/","className":"mt-8 text-sm font-medium text-slate-900 dark:text-white","children":"Go back home"}]]}]}],"notFoundStyles":[],"styles":null}]}]}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/9467422f3158babf.css","precedence":"next","crossOrigin":""}]],"$L8"]]]] 9:I[4841,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","802","static/chunks/app/docs/controller/page-810a2a590952fdc2.js"],"DocsHeader"] a:I[659,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","802","static/chunks/app/docs/controller/page-810a2a590952fdc2.js"],"Fence"] b:I[5357,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","802","static/chunks/app/docs/controller/page-810a2a590952fdc2.js"],"PrevNextLinks"] c:I[3184,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","802","static/chunks/app/docs/controller/page-810a2a590952fdc2.js"],"TableOfContents"] 2:[["$","div",null,{"className":"min-w-0 max-w-2xl flex-auto px-4 py-16 lg:max-w-none lg:pl-8 lg:pr-0 xl:px-16","children":[["$","article",null,{"children":[["$","$L9",null,{"title":"Controller"}],["$","div",null,{"className":"prose prose-slate max-w-none dark:prose-invert dark:text-slate-400 prose-headings:scroll-mt-28 prose-headings:font-display prose-headings:font-normal lg:prose-headings:scroll-mt-[8.5rem] prose-lead:text-slate-500 dark:prose-lead:text-slate-400 prose-a:font-semibold dark:prose-a:text-sky-400 prose-a:no-underline prose-a:shadow-[inset_0_-2px_0_0_var(--tw-prose-background,#fff),inset_0_calc(-1*(var(--tw-prose-underline-size,4px)+2px))_0_0_var(--tw-prose-underline,theme(colors.sky.300))] hover:prose-a:[--tw-prose-underline-size:6px] dark:[--tw-prose-background:theme(colors.slate.900)] dark:prose-a:shadow-[inset_0_calc(-1*var(--tw-prose-underline-size,2px))_0_0_var(--tw-prose-underline,theme(colors.sky.800))] dark:hover:prose-a:[--tw-prose-underline-size:6px] prose-pre:rounded-xl prose-pre:bg-slate-900 prose-pre:shadow-lg dark:prose-pre:bg-slate-800/60 dark:prose-pre:shadow-none dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10 dark:prose-hr:border-slate-800","children":[["$","p",null,{"children":["Since Stormmore has own class loader you can add controller to ",["$","strong",null,{"children":"src"}]," directory and it will work.",["$","br",null,{}],"No need to register class (including controllers etc.)."," ","Only ",["$","code",null,{"children":"#[Controller]"}]," annotation is required."]}],["$","div",null,{"className":"my-8 flex rounded-3xl p-6 callout bg-amber-50 dark:bg-slate-800/60 dark:ring-1 dark:ring-slate-300/10","children":[["$","svg",null,{"aria-hidden":"true","viewBox":"0 0 32 32","fill":"none","className":"h-8 w-8 flex-none [--icon-foreground:theme(colors.amber.900)] [--icon-background:theme(colors.amber.100)]","children":[["$","defs",null,{"children":[["$","radialGradient",null,{"cx":0,"cy":0,"r":1,"gradientUnits":"userSpaceOnUse","id":":S1:-gradient","gradientTransform":"rotate(65.924 1.519 20.92) scale(25.7391)","children":[["$","stop","0",{"stopColor":"#FDE68A","offset":".08"}],["$","stop","1",{"stopColor":"#F59E0B","offset":".837"}]]}],["$","radialGradient",null,{"cx":0,"cy":0,"r":1,"gradientUnits":"userSpaceOnUse","id":":S1:-gradient-dark","gradientTransform":"matrix(0 24.5 -24.5 0 16 5.5)","children":[["$","stop","0",{"stopColor":"#FDE68A","offset":".08"}],["$","stop","1",{"stopColor":"#F59E0B","offset":".837"}]]}]]}],["$","g",null,{"className":"dark:hidden","children":[["$","circle",null,{"cx":20,"cy":20,"r":12,"fill":"url(#:S1:-gradient)"}],["$","path",null,{"d":"M3 16c0 7.18 5.82 13 13 13s13-5.82 13-13S23.18 3 16 3 3 8.82 3 16Z","fillOpacity":0.5,"className":"fill-[var(--icon-background)] stroke-[color:var(--icon-foreground)]","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round"}],["$","path",null,{"d":"m15.408 16.509-1.04-5.543a1.66 1.66 0 1 1 3.263 0l-1.039 5.543a.602.602 0 0 1-1.184 0Z","className":"fill-[var(--icon-foreground)] stroke-[color:var(--icon-foreground)]","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round"}],["$","path",null,{"d":"M16 23a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z","fillOpacity":0.5,"stroke":"currentColor","className":"fill-[var(--icon-background)] stroke-[color:var(--icon-foreground)]","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round"}]]}],["$","g",null,{"className":"hidden dark:inline","children":["$","path",null,{"fillRule":"evenodd","clipRule":"evenodd","d":"M2 16C2 8.268 8.268 2 16 2s14 6.268 14 14-6.268 14-14 14S2 23.732 2 16Zm11.386-4.85a2.66 2.66 0 1 1 5.228 0l-1.039 5.543a1.602 1.602 0 0 1-3.15 0l-1.04-5.543ZM16 20a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z","fill":"url(#:S1:-gradient-dark)"}]}]]}],["$","div",null,{"className":"ml-4 flex-auto","children":[["$","p",null,{"className":"m-0 font-display text-xl text-amber-900 dark:text-amber-500","children":"Class loader"}],["$","div",null,{"className":"prose mt-2.5 text-amber-800 [--tw-prose-underline:theme(colors.amber.400)] [--tw-prose-background:theme(colors.amber.50)] prose-a:text-amber-900 prose-code:text-amber-900 dark:text-slate-300 dark:[--tw-prose-underline:theme(colors.sky.700)] dark:prose-code:text-slate-300","children":["$","p",null,{"children":["In development environment class loader scans entire ",["$","em",null,{"children":"src"}]," directory in order to find components."," ","Remember to switch to different environment to use cache."]}]}]]}]]}],["$","$La",null,{"language":"php","children":"namespace frontend;\n\nuse Controller, Route, Request, View;\n\n#[Controller]\n#[Route('/articles')]\nclass ArticleController\n{\n function index()\n {\n echo \"Great news! First controller in Stormmore is made.\";\n }\n}\n"}],["$","h2",null,{"id":"components-injection","children":"Components Injection"}],["$","p",null,{"children":"Add needed components as constructor or method arguments."}],["$","$La",null,{"language":"php","children":"namespace frontend;\n\nuse Controller, Route, Request, View;\n\n#[Controller]\n#[Route('/articles')]\nclass ArticleController\n{\n public function __construct(\n private Request $request,\n private Response $response,\n private ArticleService $articleService)\n {\n }\n \n function index(Request $request)\n {\n }\n}\n"}],["$","h2",null,{"id":"routing","children":"Routing"}],["$","p",null,{"children":["Annotation ",["$","code",null,{"children":"#[Route]"}]," is responsible for defining route."]}],["$","h3",null,{"id":"controller","children":"Controller"}],["$","p",null,{"children":["In case annotation over controller routes are build by name of route and concatenated with methods name.",["$","br",null,{}],"By default ",["$","code",null,{"children":"index"}]," is empty segment."]}],["$","h3",null,{"id":"method","children":"Method"}],["$","p",null,{"children":"In case annotation over method route is directly mapped."}],["$","h3",null,{"id":"controller-and-action","children":"Controller and action"}],["$","p",null,{"children":"It's possible."}],["$","h3",null,{"id":"slug-parameters-as-url-segment","children":"Slug - parameters as url segment"}],["$","p",null,{"children":["To do that mark route parameter with ",["$","code",null,{"children":":"}]," for instance",["$","br",null,{}],["$","code",null,{"children":"#[Route('/product/:name/:id))"}]]}],["$","h3",null,{"id":"example-of-routes","children":"Example of routes"}],["$","$La",null,{"language":"php","children":"namespace frontend;\n\nuse Controller, Route, Request, View;\n\n#[Controller]\n#[Route('/articles')]\nclass ArticleController\n{\n /*\n * /articles \n */\n function index()\n {\n }\n \n /*\n * /articles/featured\n */\n function featured()\n { \n }\n \n /*\n * /newest\n */\n #[Route('/newest')]\n function newest()\n {\n }\n \n /*\n * for instance\n * /what-a-beautiful-day/77\n */\n #[Route('/:name/:id')]\n function read(Request request)\n {\n echo $request->getParameter('name');\n }\n}\n"}],["$","h2",null,{"id":"output","children":"Output"}],["$","p",null,{"children":"Handles views, objects (encoded to json) and redirects"}],["$","$La",null,{"language":"php","children":"namespace backend;\n\nuse Controller, Route, Request, View;\n\n#[Controller]\n#[Route('/articles')]\nclass ArticleController\n{\n public function __construct(\n private Request $request,\n private Response $response,\n private ArticleFinder $articleFinder)\n {\n }\n \n function add() \n { \n //redirect to read url\n return redirect('/read/77')\n }\n \n function list()\n {\n //return objects array which will be encoded to JSON\n return $this->articleFinder->list();\n }\n \n function read()\n {\n $articleId = $this->request->getParameter('id');\n $article = $this->articleFinder->find($articleId);\n \n $view = view('@templates/article')\n $view->article = $article;\n \n // return html from template\n return $view;\n }\n \n function delete() \n {\n //redirect to HTTP_REFERER if available otherwise to '/';\n return back('/') \n }\n}\n"}]]}]]}],["$","$Lb",null,{}]]}],["$","$Lc",null,{"tableOfContents":[{"level":2,"id":"components-injection","title":"Components Injection","children":[]},{"level":2,"id":"routing","title":"Routing","children":[{"level":3,"id":"controller","title":"Controller"},{"level":3,"id":"method","title":"Method"},{"level":3,"id":"controller-and-action","title":"Controller and action"},{"level":3,"id":"slug-parameters-as-url-segment","title":"Slug - parameters as url segment"},{"level":3,"id":"example-of-routes","title":"Example of routes"}]},{"level":2,"id":"output","title":"Output","children":[]}]}]] 8:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"Stormmore Guide - Controller - Docs"}],["$","meta","3",{"name":"description","content":"Build application and cache everything until it change with cache API"}],["$","link","4",{"rel":"icon","href":"/favicon.ico","type":"image/x-icon","sizes":"16x16"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null