1"use strict";(self.webpackChunkapiato_documentation=self.webpackChunkapiato_documentation||[]).push([[16557],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>a});var o=t(96540);const i={},r=o.createContext(i);function l(e){const n=o.useContext(r);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),o.createElement(r.Provider,{value:n},e.children)}},87478:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>a,default:()=>p,frontMatter:()=>l,metadata:()=>o,toc:()=>s});const o=JSON.parse('{"id":"components/optional-components/middleware","title":"Middleware","description":"Apiato middleware are just Laravel Middleware,","source":"@site/versioned_docs/version-13.x/components/optional-components/middleware.md","sourceDirName":"components/optional-components","slug":"/components/optional-components/middleware","permalink":"/docs/components/optional-components/middleware","draft":false,"unlisted":false,"editUrl":"https://github.com/apiato/documentation/tree/master/versioned_docs/version-13.x/components/optional-components/middleware.md","tags":[{"inline":true,"label":"component","permalink":"/docs/tags/component"},{"inline":true,"label":"optional-component","permalink":"/docs/tags/optional-component"},{"inline":true,"label":"middleware","permalink":"/docs/tags/middleware"},{"inline":true,"label":"service-provider","permalink":"/docs/tags/service-provider"},{"inline":true,"label":"route","permalink":"/docs/tags/route"},{"inline":true,"label":"controller","permalink":"/docs/tags/controller"},{"inline":true,"label":"request","permalink":"/docs/tags/request"}],"version":"13.x","lastUpdatedBy":"Mohammad Alavi","lastUpdatedAt":1746631000000,"frontMatter":{"title":"Middleware","tags":["component","optional-component","middleware","service-provider","route","controller","request"]},"sidebar":"tutorialSidebar","previous":{"title":"Mail","permalink":"/docs/components/optional-components/mail"},"next":{"title":"Migrations","permalink":"/docs/components/optional-components/migrations"}}');var i=t(74848),r=t(28453);const l={title:"Middleware",tags:["component","optional-component","middleware","service-provider","route","controller","request"]},a=void 0,d={},s=[{value:"Rules",id:"rules",level:2},{value:"Folder Structure",id:"folder-structure",level:2},{value:"Code Example",id:"code-example",level:2}];function c(e){const n={a:"a",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.p,{children:["Apiato middleware are just ",(0,i.jsx)(n.a,{href:"https://laravel.com/docs/middleware",children:"Laravel Middleware"}),",\nand they function in the exact same way as Laravel middleware.\nHowever, they come with additional rules and conventions specific to Apiato."]}),"\n",(0,i.jsxs)(n.p,{children:["To generate new middleware,\nyou may use the ",(0,i.jsx)(n.code,{children:"apiato:make:middleware"})," interactive command:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"php artisan apiato:make:middleware\n"})}),"\n",(0,i.jsx)(n.h2,{id:"rules",children:"Rules"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["All container-specific Middleware:","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["MUST be placed in the ",(0,i.jsx)(n.code,{children:"app/Containers/{Section}/{Container}/Middleware"})," directory."]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["All general Middleware:","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["MUST be placed in the ",(0,i.jsx)(n.code,{children:"app/Ship/Middleware"})," directory."]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["All Middleware MUST extend the ",(0,i.jsx)(n.code,{children:"App\\Ship\\Parents\\Middleware\\Middleware"})," class.","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["The parent extension SHOULD be aliased as ",(0,i.jsx)(n.code,{children:"ParentMiddleware"}),"."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"folder-structure",children:"Folder Structure"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-php",children:"app\n\u251c\u2500\u2500 Containers\n\u2502 \u2514\u2500\u2500 Section\n\u2502 \u2514\u2500\u2500 Container\n\u2502 \u2514\u2500\u2500 Middleware\n\u2502 \u251c\u2500\u2500 DemoMiddleware.php\n\u2502 \u2514\u2500\u2500 ...\n\u2514\u2500\u2500 Ship\n \u2514\u2500\u2500 Middleware\n \u251c\u2500\u2500 AnotherMiddleware.php\n \u2514\u2500\u2500 ...\n"})}),"\n",(0,i.jsx)(n.h2,{id:"code-example",children:"Code Example"}),"\n",(0,i.jsx)(n.p,{children:"Middleware are defined exactly as you would define them in Laravel."})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.