{"_id":"5771ff2901e8110e0041adae","version":{"_id":"576ebdb79c84a31900958abd","project":"576ebdb79c84a31900958aba","__v":10,"createdAt":"2016-06-25T17:21:59.854Z","releaseDate":"2016-06-25T17:21:59.854Z","categories":["576ebdb79c84a31900958abe","576ebfc59c84a31900958ac4","576ec32f52f96619007cfb9a","576ec7b7560eef0e00cd3096","576ed4249c84a31900958add","576ed429560eef0e00cd30a3","576ed43a52f96619007cfbb5","576ed44d5a8c72170082b794","577212f20da40019004f0816","57725c7e0a6d610e00de9e4c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.3.0","version":"3.3"},"__v":12,"parentDoc":null,"githubsync":"","project":"576ebdb79c84a31900958aba","user":"576ebd239c84a31900958ab9","category":{"_id":"576ec7b7560eef0e00cd3096","version":"576ebdb79c84a31900958abd","__v":0,"project":"576ebdb79c84a31900958aba","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-25T18:04:39.266Z","from_sync":false,"order":3,"slug":"deployment","title":"Basics"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-28T04:38:01.307Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Asset Component is a port of Laravel 3 Asset for Orchestra Platform. The component main functionality is to allow asset declaration to be handle dynamically and asset dependencies can be resolve directly from the container. It however is not intended to becoma an asset pipeline package for Laravel, for such purpose we would recommend to use Grunt or Gulp.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Register\"\n}\n[/block]\nThe Asset class provides a simple way to manage the CSS and JavaScript used by your application. To register an asset just call the add method on the Asset class:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nAsset::add('jquery', 'js/jquery.js');\\nAsset::add('bootstrap', 'js/bootstrap.js', ['jquery']);\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"<head>\\n\\t{!! Asset::styles() !!}\\n  {!! Asset::scripts() !!}\\n</head>\\n\\n<!-- or using show() method -->\\n\\n<head>\\n  {!! Asset::show() !!}\\n</head>\",\n      \"language\": \"html\",\n      \"name\": \"Blade\"\n    }\n  ]\n}\n[/block]\nThe add method accepts three parameters. The first is the name of the asset, the second is the path to the asset relative to the public directory, and the third is a list of asset dependencies (more on that later). Notice that we did not tell the method if we were registering JavaScript or CSS. The add method will use the file extension to determine the type of file we are registering.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Dependencies\"\n}\n[/block]\nSometimes you may need to specify that an asset has dependencies. This means that the asset requires other assets to be declared in your view before it can be declared. Managing asset dependencies couldn't be easier in Orchestra Platform. Remember the \"names\" you gave to your assets? You can pass them as the third parameter to the add method to declare dependencies:\n\nRegistering a bundle that has dependencies:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nAsset::add('jquery-ui', 'js/jquery-ui.js', 'jquery');\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nIn this example, we are registering the jquery-ui asset, as well as specifying that it is dependent on the jquery asset. Now, when you place the asset links on your views, the jQuery asset will always be declared before the jQuery UI asset. Need to declare more than one dependency? No problem:\n\nRegistering an asset that has multiple dependencies:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nAsset::add('jquery-ui', 'js/jquery-ui.js', ['first', 'second']);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Containers\"\n}\n[/block]\nTo increase response time, it is common to place JavaScript at the bottom of HTML documents. But, what if you also need to place some assets in the head of your document? No problem. The asset class provides a simple way to manage asset containers. Simply call the container method on the Asset class and mention the container name. Once you have a container instance, you are free to add any assets you wish to the container using the same syntax you are used to:\n\nRetrieving an instance of an asset container:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nAsset::container('footer')->add('example', 'js/example.js');\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"<footer>\\n  {!! Asset::container('footer')->scripts() !!}\\n</footer>\",\n      \"language\": \"html\",\n      \"name\": \"Blade\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Versioning\"\n}\n[/block]\nAnother option to increase response time is by utilizing browser caching, while there few ways to do this we pick last modified time as our way to version the Asset.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nAsset::container()->addVersioning();\\n\\n# or alternatively\\n\\nAsset::addVersioning();\",\n      \"language\": \"php\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nYou can remove adding versioning number by using:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nAsset::container()->removeVersioning();\\n\\n# or alternatively\\n\\nAsset::removeVersioning();\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"This would only work with local asset.\",\n  \"title\": \"Versioning Limitation\"\n}\n[/block]","excerpt":"","slug":"asset","type":"basic","title":"Asset"}
Asset Component is a port of Laravel 3 Asset for Orchestra Platform. The component main functionality is to allow asset declaration to be handle dynamically and asset dependencies can be resolve directly from the container. It however is not intended to becoma an asset pipeline package for Laravel, for such purpose we would recommend to use Grunt or Gulp. [block:api-header] { "type": "basic", "title": "Register" } [/block] The Asset class provides a simple way to manage the CSS and JavaScript used by your application. To register an asset just call the add method on the Asset class: [block:code] { "codes": [ { "code": "<?php\n\nAsset::add('jquery', 'js/jquery.js');\nAsset::add('bootstrap', 'js/bootstrap.js', ['jquery']);", "language": "php" }, { "code": "<head>\n\t{!! Asset::styles() !!}\n {!! Asset::scripts() !!}\n</head>\n\n<!-- or using show() method -->\n\n<head>\n {!! Asset::show() !!}\n</head>", "language": "html", "name": "Blade" } ] } [/block] The add method accepts three parameters. The first is the name of the asset, the second is the path to the asset relative to the public directory, and the third is a list of asset dependencies (more on that later). Notice that we did not tell the method if we were registering JavaScript or CSS. The add method will use the file extension to determine the type of file we are registering. [block:api-header] { "type": "basic", "title": "Dependencies" } [/block] Sometimes you may need to specify that an asset has dependencies. This means that the asset requires other assets to be declared in your view before it can be declared. Managing asset dependencies couldn't be easier in Orchestra Platform. Remember the "names" you gave to your assets? You can pass them as the third parameter to the add method to declare dependencies: Registering a bundle that has dependencies: [block:code] { "codes": [ { "code": "<?php\n\nAsset::add('jquery-ui', 'js/jquery-ui.js', 'jquery');", "language": "php" } ] } [/block] In this example, we are registering the jquery-ui asset, as well as specifying that it is dependent on the jquery asset. Now, when you place the asset links on your views, the jQuery asset will always be declared before the jQuery UI asset. Need to declare more than one dependency? No problem: Registering an asset that has multiple dependencies: [block:code] { "codes": [ { "code": "<?php\n\nAsset::add('jquery-ui', 'js/jquery-ui.js', ['first', 'second']);", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Containers" } [/block] To increase response time, it is common to place JavaScript at the bottom of HTML documents. But, what if you also need to place some assets in the head of your document? No problem. The asset class provides a simple way to manage asset containers. Simply call the container method on the Asset class and mention the container name. Once you have a container instance, you are free to add any assets you wish to the container using the same syntax you are used to: Retrieving an instance of an asset container: [block:code] { "codes": [ { "code": "<?php\n\nAsset::container('footer')->add('example', 'js/example.js');", "language": "php" }, { "code": "<footer>\n {!! Asset::container('footer')->scripts() !!}\n</footer>", "language": "html", "name": "Blade" } ] } [/block] [block:api-header] { "type": "basic", "title": "Versioning" } [/block] Another option to increase response time is by utilizing browser caching, while there few ways to do this we pick last modified time as our way to version the Asset. [block:code] { "codes": [ { "code": "<?php\n\nAsset::container()->addVersioning();\n\n# or alternatively\n\nAsset::addVersioning();", "language": "php", "name": null } ] } [/block] You can remove adding versioning number by using: [block:code] { "codes": [ { "code": "<?php\n\nAsset::container()->removeVersioning();\n\n# or alternatively\n\nAsset::removeVersioning();", "language": "php" } ] } [/block] [block:callout] { "type": "warning", "body": "This would only work with local asset.", "title": "Versioning Limitation" } [/block]