I'm developing my website using Php and Smarty. Now , i'd like to caching the bytecode of the php script using APC, but i'm worry that APC will cache also the complied smarty's templates, loosing the possible dynamic content. Is it possible?
Tanks
I have been using APC for over a year now and without problems on four different servers and more than 30 different sites. All these sites are Smarty ones, using dynamic content literally everywhere. At the moment I am using in a pretty heavily used customer site with no problems. Not once.
APC caches the compiled templates and re-caches them when/if they are altered (compiled by the Smarty compiler). The dynamic content will work exactly as previously, it will only be a bit quicker, of course.
So go ahead and use it.
I had problems with Smarty and APC together. An Apache restart was always required when something in the template had changed to prevent errors and confused templates.
I'm using an old version of Smarty and I found other problem descriptions and solutions on the net: http://erasel.net/2009-11-09/apc-und-probleme-cache.html
To prevent a APC and Smarty mixture use this settings in the php.ini
[APC]
apc.enabled = 1
apc.cache_by_default = 1
apc.filters = "AdoDB,adodb,ADODB,Smarty,smarty,.tpl"
Yes, it is. I used to do just that. Always test on your dev machine before deployment.
Related
This is where technology is annoying. 3 days ago I upgarded from Laravel 5.3 to Laravel 5.4. Despite of a bad upgrade guide offered by Laravel documentation, totally found out I have to migrate from Gulp to Webpack (which I was not familiar with).
It's 2 Days, I'm still searching about Webpack to know how I can do a job which was so simple before. There isn't any clear notes out there. Even I can't understand what is the best practices for a website with so much styles and scripts.
Sorry for nagging so much. I'm really confused.
Assume I have 15 CSS files in two parts. 5 of them are common files which are used in both user and admin panel and both panels have 5 specific files. The same structure for JS files.
Also want to use long-term cache, whilst avoid render-blocking JavaScript files (async/defer).
With Gulp I could easily merge all Styles and JavaScripts in 3 bundles. It was so simple to async them and also long-term caching was OK.
With Webpack If I use mix.js() long-term caching is OK but I can't load them asynchronous because Webpack has it's own bootstrapper.
If I use mix.scripts() or mix.combine(), I'm able to load scripts asynchronous, but now npm run watch won't watch for changes in those javascript files.
I prefer to use what Laravel is suggesting, but that's really annoying. Where can I find a simple example of a website implemented by Laravel 5.4 and Laravel Mix?
I have seen JeffreyWay's example but that's very basic and so much far from a real website.
I want to use multiple themes in codeigniter like wordpress.
e.g
Themes are A, B, C.
if i select Theme A then html would be change Theme A wise.
if i select Theme B then html would be change Theme B wise.
etc.
please help and thanks in advance.
Hi
Very hard to give this answer because your question is very out of range. :)
But I will try my best to do this.
Many way to build different themes put in CI
1) Use of CMS in codeigniter like
->http://www.getfuelcms.com/
->http://www.nodcms.com/en
2) Second way to do this things the easy way is to build your dynamic system as per your recruitment.
Also easiest way is to build your site in wordpress.
Although the library has it years(newer php version may scream error about &=, just delete & ) you can use https://github.com/philsturgeon/codeigniter-template - it uses theme concept. But you have to build database layer for themes usage logic. And if you know, which theme your site is using, then you just use method of the library: $this->template->set_theme($my_current_theme)
If you like a complete tutorial, check out this link
http://www.roytuts.com/using-template-in-codeigniter-3/. This is just an example, however and there's many more out there.
I agree with cssBlaster21895, that library can still be made to work for modern PHP versions. I just adjusted a few things and that made the errors disappear.
I know there exists tools that migrates Joomla to Wordpress at database level. But my problem is I don't have access to Joomla database anymore. I only have whole Joomla! 1.0.x site's local copy which was taken 2 years ago. Is it possible to migrate that posts to my Wordpress site?
Or should I copy-paste all content to a CSV file and use an Excel importer ?
Not specifically for Joomla , but I have made such a thing in the past several times while migrating from some Custom Cms's
It will depend on HOW BIG is your site and how much information you need to migrate (and it's complexity) but you can always go for HTML SCRAPPING / PARSING.
As from this point , GIYBF . And your Coding skills.
One of the best one IMHO is Simple HTML DOM ,and another that many recommend but I personally never used are htmlSQL And phpquery .
But there are also a lot of Tutorials on google ( here also and EXAMPLE TUT) explaining how to do it , and also a lot of questions here on SE and a list of options (not PHP exclusive).
The other option (which is basically the same , but without libraries) , is going or REGEX , like in this very simple example..
If you don't have the DB, then you don't have the content. All of the content on a Joomla site is stored in the DB. If you only have the Joomla files, there is nothing to copy and paste in to a CSV.
Try using this script. http://azeemkhan.info/2008/joomla2wordpress-import-wizard-v3/ Note you will need to install an old version of wordpress first and THEN upgrade your wordpress version.
There's a useful guide on this here and info on utf-8 support here.
Hope this helps
I just visited the Static Website Generation on Ruby toolbox and I don't know which of applications listed there is best suited for a little blog engine. Basically I need:
an index page with 1..5 of latest articles with shortened content;
possibility to add few main pages and a menu to access them (breadcrumb optional);
show articles
show/search archives
commenting system - Disqus Ok
tag-list cloud - optional
Look&Feel via layout
Important all content will be translated in 3 languages!
I can host on my own server, so side processing is possible.
Update:
First I'll try nanoc => blog's source on github
I think nanoc worth a try it has everything you specified, even if is not the best ranked on ruby toolbox its actively developed and highly customizable.
nanoc is a tool that runs on your local computer and compiles documents written in formats such as Markdown, Textile, Haml… into a static web site consisting of simple HTML files, ready for uploading to any web server.
and thats true :) I use it for a while not specially for a blog, but it has also helpers for that...
check out jekyll, it should work well for this.
Try my own "serious" - apart from archive search and tag cloud, it has everything you specified, plus the basic install should take you something like 5 minutes on heroku (and maybe 10 on your own server via Rack). It also has syntax highlighting, Disqus comments, Google Analytics and other goodies.
http://github.com/colszowka/serious
gem install serious
Disclaimer: It does not produce static html pages you can upload to your php vhost, though. But it uses caching and is really easy to setup and works on the free plan on heroku.
A Little Background Information:
I've been looking at a few PHP framework recently, and it came down to two. The Zend Framework or CodeIgniter.
I prefer CodeIgniter, because of its simple design. It's very bare bone, and it is just kept simple. The thing I don't like though is the weak template system. The template system is important for me, because I will be working with another designer. Being able to give him a good template system is a big plus.
Zend was the second choice, because of the better template system that is built in. Zend is a different beast though compared to CodeIgniter. It emphasis "loose coupling between modules", but is a bigger framework. I don't like to feel like I have many things running under the hood that I never use. That is unnecessary overhead in my opinion, so I thought about putting a template system into CodeIgniter: Smarty.
Question(s): How easy/hard is the process to integrate Smarty into CodeIgniter? From my initial scan of the CodeIgniter documentation, I can see that the layout of the framework is easy enough to understand, and I anticipate no problems. I want to know if anyone has used it before, and therefore are aware of any "gotchas" you my have experienced that is going to make this harder than it should be or impossible to pull off. I also want to know if this is a good thing to do at all. Is the template system in CodeIgniter enough for normal use? Are there any other template modules that are good for CodeIgniter aside from Smarty? I better off with Zend Framework? Is any wheel being invented here?
Sorry to resurrect an old question - but none of the answers have been flagged as "accepted" yet.
There's a library called "template" that does a great job of allowing you to use just about any template parser you want:
Template CI Library - V1.4.1
The syntax is pretty easy for integrating into your CI application and the smarty integration spot on.
Slightly OT, hope you don't mind...
I'm a Zend Framework user and I think it's worth saying that the loose coupling means you don't need to include any files you're not actively using. Hopefully this negates your concern about unnecessary overhead.
With the layouts stuff added in a recent release of ZF, its templating is really hard to fault... and it's completely pluggable as Favio mentions. The more I use ZF, the more I like it; they do things the way I would do them!
I did a quick google search and found the following:
http://devcha.blogspot.com/2007/12/smarty-as-template-engine-in-code.html
http://codeigniter.com/forums/viewthread/67127/
If the designer is not familiar with Smarty, I think it's almost the same as if you use the existing CodeIgniter templating system (which leaves everything to PHP actually). It also depends on the complexity of the project at hand.
You can also hook Smarty with Zend Framework. It's more complex than with CodeIgniter, but there's already a primer on how to do exactly that in the ZF documentation. http://framework.zend.com/manual/en/zend.view.scripts.html Plus lots of tutorials on the net.
In my opinion it's almost the same, you can use pure PHP or Smarty as your template "engine", so it depends on the project. Also, compare a developer who has extensive experience and already has a library of view helpers so she uses pure PHP, versus a designer who doesn't know anything about PHP, but has extensive experience with Smarty. Sometimes decisions have to be based on who is going to do what.
Check out this custom CodeIgniter templating library. I've already used it on several projects and it is easy to use. I know this post is late but it's worth checking out.
It doesn't appear there has been an answer selected for this question nor has an up-to-date solution been given to work with the latest version of Codeigniter (2.0) and the latest version of Smarty (3.0.5).
This library allows you to use Smarty 3 with Codeigniter 2.0 so you can use Smarty 3 specific features like template inheritance.
http://ilikekillnerds.com/2010/11/using-smarty-3-in-codeigniter-2-a-really-tiny-ci-library/
Integrating Smarty in CodeIgniter? It is a breeze!
The template system in CodeIgniter is very basic.
Follow these steps for Smarty 3 in CI 3:
Download CodeIgniter 3
Download Smarty 3 and put its content in 'application/third_party/smarty' folder
Create 'Custom_smarty.php' file in 'application/libraries' and add this code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'third_party/smarty/Smarty.class.php');
class Custom_smarty extends Smarty {
function __construct()
{
parent::__construct();
$this->setTemplateDir(APPPATH.'views/templates/');
$this->setCompileDir(APPPATH.'views/templates_c/');
}
}
?>
Create 'templates' & 'templates_c' folders inside 'application/views' folder
Create simple 'test.tpl' file in 'application/views/templates' folder
Open 'autoload.php' in 'application/config' folder and add:
$autoload['libraries'] = array('custom_smarty');
And inside a controller: $this->custom_smarty->display('test.tpl');
If you are working on localhost set the permissions: sudo chmod -R 777 templates_c. Otherwhise contact your hosting service, if you catch the error Unable to write file. First be sure templates_c folder exists.
Otherwise you can use another template engine like Twig.