Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have recently start work with twig in my project,
I have check that twig have create cache folder, and check that twig basically create some php classes for cache,
I want to understand exactly how this mechanism is work, how it beneficial to reduce the page loading time, any one can help me ?
Twig evaluation process looks like:
Your templates are parsed, abstract syntax tree (AST) is built from then and then AST is transformed into php code
Php code from the step #1 is evaluated
With Twig templates caching you eliminate step #1, since the transformation results are written to a cache files.
So it is highly recommended to use it on production. Just make sure you clear the template directory cache on deploy or specify another directory as a target. It could be a good idea to include the application version number in the path.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm having a trouble on how to implement Single Page Application on Laravel blade php file format using Vue-router, is that possible?.The reference link below says that it is impossible to use SPA on php file format and I'm here to ask to confirm if this is not possible, but I guess there is other solution with this issue. It would be great if anybody could figure out, thank you so much in advance!.
Reference
For example with this file it should blade.php instead of vue
Not possible ..laravel have some standards that need to follow
Blade view files use the .blade.php file extension and are typically stored in the resources/views directory.
SPA are fast since most resources (HTML,CSSS,Scripts etc) and DOM components are only loaded once throughout the entire cycle of an application. Subsequently, only dynamic content is loaded by JS, which speeds up the site remarkably.
If you are using blade then it needs to reload for every changes to reflect then what points of using it
Refer this: https://laravel-news.com/using-vue-router-laravel
Personally I would opt for L8 with inertiajs(vuejs) which is integrated in the documentation and you can easily make a SPA
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
How do we write files that are included in a php webpage using includes or requires.
(1)Is there any programming convention for the stuff?
For example: Do you add title in the header/footer file or not? if yes won't there be two titles one from the file included and one of the file that is including the footer/header file. What about bootstrap/js files do I include them in header/footer file or not? Because header/footer contain the usage of bootstrap classes.Won't importing them again and again increase the loading time of pages? (2)So basically do we add head section? if yes how do these values affect the current document?
As I am just beginner I would be glad if you could share some example that has html and php code in the file that gets included. Along with bit of explanation regarding the questions above (1&2). Thank you.
Instead of asking about includes or requires for rendering conventions I would suggest you learn how does a "Render Engine" works. For example Twig (from Symfony), Blade (from Laravel) or Mustache.
Basically, because you should want to distinguish between the different layers in your system. The rendering layer should not contain any other logic but rendering.
The easiest approach here, especially if you're new, is to go with the MVC (Model-View-Controller). And from there you can escalate the structure.
The answer for this question "Adding header or footer in php" is basically Twig or Blade.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
for some a reason I need to track entry point of laravel framework,how can I do that, is there any way to do that, I need to debug also how can laravel load service provider of package step by step is there any way or something like so, I ask just if can tell me how?
and what I mean by track?
I mean to display stack trace when laravel run, to see variables loaded into memory.
Entry point is ./public/index.php. For debugging people usually use xdebug but I never really needed it. I usually just dd($something). If you have laravel 6 you have ddd() helper that dumps the variable but also shows you the stack trace and other useful info. You can ddd() directly in the ./vendor in the provider if you want. Put any variables you want to see in the ddd. If you don't have laravel 6 then you can throw an exception to see the trace or dd() whatever you want to see. There are other ways of course but this was always enough for me.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to optimise PHP code to manage code easily and to speedup page execution time. My strategy is to create a file core_functions.php and defined all functions in this file. Then include this file into every other file of the project.
I need to know is it best practice to have all function defined in one file or it is best practice to split the function into different files and include where needed.
What you're doing is actually going to hurt performance. In each page that loads the 6000 line file the PHP interpreter has to interpret that whole file. You'd be better of splitting your functions into modules and have each page only reference the modules it needs.
This reinterpretation of PHP files on each page load can be reduced though by using a caching mechanism that caches the compiled byte code of interpreted files.
There is a list of frameworks that do this here: http://en.wikipedia.org/wiki/List_of_PHP_accelerators
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
i'm working on a big project. i'm using codeigniter, but i'm facing a hard question, where should i using codeigniter caching. should i use it inside models? or in the controller? also as my project is big, i'm facing a hard time trying to guess what caches should i delete as the codeigniter caching is depending on the controller name, so when i update a table i have to check all controllers that are using that table and delete their cache. that kills me.
what is the best practice for this?
Thanks
CodeIgniter have a good cache for small projects, but when you need to exclude things, it gets kind of messy. It's not decentralized.
A good solution for query cache is http://code.google.com/p/improved-query-caching/ and as Wesley told you, http://philsturgeon.co.uk/code/codeigniter-cache.
I also don't recommend using the query cache for ALL your queries, but instead using the ones that really needs it. It depends a LOT in the project and its size.
Remember that cache use only view. For example if you want to change language on the site it doesnt work because codeigniter will load old wiev with old language. And then you must wait untill new cache will be created and loaded with language which is currently set.