I have a web application, that uses Yii2, that I would like to make it work on a read only file system.
For the caching components, is quite easy. There is other options, like database, or Redis, etc.
But I have some specific uses, like for example, the HTML purifier, that, to purify a string, needs a runtime folder access, to process stuff.
How to attend these specific cases? Ditch everything that can't be done in memory, or not in a cloud storage, like S3, for example?
Thanks in advance.
Related
I have php db driven website that uses a lot of flash for user interaction.
I need to make it multilangual like 20+ languages.
Site is quite large and has a lot of users coming to it every day.
Other developer i work with saying we should store translation in local files e.g. /lang/english.php /lang/german.php etc.
I was thinking since database is on the same dedicated server there should not be a slow down, which way you think will work is faster?
I don't know if it's an option, but you could also use gettext().
That way your translations are stored in local files (faster than a database) and you have the advantage that there are programs like poedit (takes some getting used to...) that you or a translator can use to automatically generate the translation files so it's a bit easier to maintain then php files.
Local files are a LOT faster than DB content (Although you can save the DB output in a local cache, like files or even memcache or APC), probably not that easy to translate, but it will help you with the basic speed of implementation too, You should take a look at:
http://framework.zend.com/manual/en/zend.translate.html
You can use only this part of the framework and it will give you a HUGE boost, it supports DB based translation or local files (a lot of adapters)
UPDATE:
thanks Corbin, you are right, it's better to have the direct link.
I'd like to get apache, mysql, and php running in an iphone app. This is because I'm finding objective c to be quite difficult, and if I can get those three running and figure out how to set up a full-page browser or something, I can code my app like that.
The MySQL aspect isn't really a necessity since I can very easily code a flat file database in php for this.
Is this possible? Has it been done? If not, what frameworks should I use to make creating an app easier?
I am assuming what you are saying is that you are more familiar with HTML and JavaScript, and would like to code with those tools.
If so, take a look at PhoneGap and Titanium. They are frameworks to code iOS apps with web technologies. Basically, it is like running a local file in a web browser (with interfaces to access device functions such as the GPS). No need to have a PHP and Apache stack there.
There is also a quasi-standard to write web applications that can work offline once downloaded. Mobile Safari supports this, and it can almost look like a native app.
If you're looking for any other options, there's Mono Touch, which is C# for iPhone. It's garbage collected, managed, strongly typed, and has access to all the device functions just like PhoneGap.
There's not really any simple way to get PHP running on an iPhone. You could try to get it to compile yourself, but that sounds like you'd be spending more time trying to get the framework working rather than working on your actual project.
im just soliciting opinions/advices. Like we have this really large PHP code base, by large these are what i meant:
over 500 tables
over 4000 files - action, displays & templates.
over 1,000,000 lines of code - this software spans more than 8 years already.
So many deprecated, duplicated code all over the place, and so many hacks.
I want to be able to still run the software, while parts of it are being migrated to rails.
So it will be running in hybrid mode, that is, both PHP and rails at the same time. Parts of the software that hav been migrated already, will start using the Rails version.
I suppose my idea is:
migrate to Git
I suppose all the more than 500 tables remain.
Find a way so PHP and rails will interoperate?
Chew one display & management screen at a time?
Work on the front end?
I expect such a thing is going to be toff. Anyway let me try to give some advice.
Build both basic "runnable" applications.
Make sure that both applications can access the same database, the same session sources, the same cache and so on. Here'll you have to make sure that that your data sources are compatible to both your applications. For example: you could migrate your user sessions to the database.
Build an extra routing component (in mod_rewrite, PHP or whatever you like) to start routing several pages to your Ruby application instead to PHP. Test it thorougly. Build the router in such way that it can function in development mode as well as in production mode.
Slowly start adding routes to your router for added components in your Ruby application.
When you've completely migrated, change the default route to your Ruby application. You can start using Ruby-specific data sources now.
While I'm far from convinced that migrating from PHP to Ruby will make your life any easier, I think there is a very strong case for mapping out the dependencies within the current codebase.
Which PHP scripts are entry points to execution (i.e. map directly to URLs)
which PHP files are included by other scripts (and which are they)
which templates are used by which URL
which scripts access which tables
That will at least allow you to divide the exercise up into discrete chunks. Note that in some cases it may be a good idea to rewrite the PHP / DB as an interim measure instead of going directly to Ruby, e.g.
If there is scope for amalgamating several database tables - then do so - and create views on the resulting table named according to the replaced table.
If needed, try to re-implement every entry point PHP script as 'index.php' in its own directory - and always reference the script by the directory. That way you can transparently start replacing components written in a different language.
I want to make a news portal(php) with minimum mysql force.
:create a cron, fetch data from mysql and write to a php file . (I dont know is it right way)
But Can I use xml instead of php file? Write mysql data to xml.
Is this a secure way? What is the best way? XML or php file?
alt text http://img541.imageshack.us/img541/4784/87392425.gif
Thanks in advance
Let me start of by saying that MySQL is very fast and very secure. I recommend building the pages with MySQL upon request, most web applications do this because its a very good approach. To save resources you can cache the output using a Squid Reverse Proxy, and it is very common to see this on high traffic sites. PHP's APC will also reduce resource consumption without sacrificing secuirty. Smarty's Caching system is also a good approach with minimal security impact.
There are secuirty concerns regardless of what method you choose, but some approaches more hazardous than others. For instance creating .php files with user input is probably the most dangerous thing you can attempt to do with a php web app.
$page='$title="'.$_GET['user_title'].'"';
file_put_contents("/var/www/page.php",$page);
An attack against this code would look like this:
http://localhost/page_creater.php?user_title='; eval($_GET[backdoor]); /*
Creating XML files with user input is also dangerous because it opens the door for Advanced LFI Attacks. However, the counter argument is that as long as your application is free from Local File Include vulnerabilities, then you shouldn't have to worry. But this is not a "Defense in-depth" design, because you should plan on failure.
Its possible to implement something like Squid's reverse proxy in php using ob_start(), however your still creating files with attacker controlled data, and that is hazardous. Also don't include() .html files that's incredibly stupid (See advanced LFI attacks...), a better approach is this: print(file_get_contents($file)). I do like using .html files over using .xml files because html doesn't have to be processed before outputting it to the user. Using xml files as a data storage is wasteful of resources when compared to MySQL.
(Disclaimer: Vulnerabilities have been found in Smarty and squid, and php, and linux, and mysql and apache and.... everything else, even StackOverflow ;)
i got some ideas for a blog/folio but i dont want to get a paid web server yet (still studying not really earning yet), and i thought of working on some ideas i thought will ease my blogging workflow. let me know if i can don't re-invent the wheel too much. or ideas on what i shld use
overall i think i will use adobe air + flex + db (i think MySQL/SqlLite) + scripting lang (php/zend framework, if needed)
will silverlight be better? it has C# which can do more, and since this is more of a desktop app
i dont have a web server.
free ones dont seem too reliable. so i thought of self hosting. like a desktop app.
i am thinking of using Adobe AIR + Flex (i am a web developer but seem to feel some of the Flex stuff looks great, esp Flex 4's Flash Catalyst/Builder's integration with Adobe Illustrator and Photoshop). Sometimes i get headaches with CSS bugs ... embarrassing ... i know
self hosting. i seem to format alot ... i may forget to backup my MySQL database
any database thats portable and reliable (overtime, the data may get big)? MSSQL is able to store db files in App_Data, thats 1 solution? SqlLite is another? i normally use MySQL any such solution?
as for file storage, i am thinking i use a SD card, that way when i format it wont affect anything? i dunno abt speed/size tho ... i think i will be storing quite abit of images. at most i allocate a partition for it.
Wordpress/Joomla is web based and on a hosted server, going from page to page takes time.
i wanted something fast and can integrate into my desktop - like gadgets - so i can post easily. i think adobe air makes the cut here too, tho its not really a gadget.
better "image/file" management. like auto generating lightbox gallery from images
i think wordpress now has something like that with gallery short tag. with air i am thinking of making a way that i can manipulate (rotate/resize) images easily to create thumbnails, probably attach descriptions and tags.
is there any way i can work with the meta info? does meta info only exists for images. so i can create something like a file manager. i am getting inspired by adobe bridge.
I also like to manage my images/fonts (source and license)
being a web developer and with SIFR, i can use custom fonts. but i want some way i can track font license and source. some fonts dont allow for embedding and commercial use for example. i dont see any font manager that does that.
probably i use a db table for this. any other ideas. how can i read & display fonts? ttf, otf i think are the 2 main kinds i am using
i think these are all for now
Ok, big question, I'll answer it in stages:
For starters, self-hosting is going to produce a slow, bad user experience for anyone who visits your website. Response times will be bad, it will be up and down as your internet connection varies, and you'll have the lovely experience of having your internet get slow anytime someone browses your page.
Bottom line, DON'T SELF HOST.
If you insist on doing so, use sqlite is probably the easiest of the database technologies to move around. Since it's all flat files, and requires no running server, you won't have many of the issues associated with migrating a mysql install.
As far as technologies, if you're writing a web app, use web technologies. You mention that it takes a long time to go between pages on wordpress/joomla, but think about how much longer than that it takes for your users to load up whatever monstrosity you may have concocted in flex! Flex is designed for data-heavy database powered applications that would normally be written in something like visual basic. It allows those apps to be integrated into a website, but it's really a terrible way to build a blog.
If you want to be able to post from your desktop, consider using one of the XML-RPC desktop clients that post directly to a wordpress blog.
Bottom line, don't reinvent the wheel. Use wordpress, it's damn good at what it does. Since you don't have your own hosting, host at wordpress.com, it's free and very reliable.
Learn Django!
You can run it locally using a sqlite database, which solves your latency problems, and the ORM is a dream to work with, super-simple to extend, and you'll spend your time learning to use a really powerful system rather than debugging hacked together php scripts.
You can create a database model that will store anything you like, including all the fonts, images, files, and anything else you can imagine. The model ORM frees you from many of the mundane tasks associated with these things, and lets you concentrate on the logic and features you want to have in your app.
Using Django would allow you to build all the features you discussed in your post.