I am working on making a search engine, I have to store multiple data against one word, how it will be done using php without use of JSON.
and is it a good approach to do this work in php or I should switch to another Object Oriented Programming Language ?
If its research project, you could give a shot with PHP7 (its faster). PHP5 will also let you achive what you want.
What language you chose is mainly dependand on what you want to achieve. C++ is surely faster than PHP.
Also you would need to check about bigdata handling and non-relational databases (MongoDB for example) which are scalable.
Related
I have some data which I rarely have to update. Further I want that data to be very fast to access. What kind of solution do you recommend me in Zend Framework. The options I thaught are a Mysql database, some XML files, or directly writing the data in php arrays... Is there any ORM library I should use?
Since you're already using Zend Framework, why not use Zend_Config and store the data as ini/xml/json/yaml.
That's how Zend already stores your application settings. And if it's really not that much data, just store it in application.ini.
I'd say you can use whatever you want in your backend but then wrap it in Zend_Cache. This way you have some control over a refresh cycle but also the data in a convenient way and fast access.
Don't use an ORM if your aiming at fast access. Use an ORM for easy developing.
The fastest solution is storing this data in a plain PHP array I guess. But it's not the best solution if you ask me.
What kind of data are we talking about? How often and when does is change?
Store your data in a MySQL database but also index it using Zend_Search_Lucene.
Retrieving the data from a Lucene index is pretty fast from my experience
My favorite option in this cases is use Zend Cache. If you want to optimize the response time even more you can use the memcached library http://memcached.org/ . That can be used with Zend_Cache with little effort.
I have a PHP application and now I need to implement multi language support. This is the first time I have to deal with this.
I did some searches on the internet and always come to PHP's gettext function, which I have compiled on my server.
I would just like to know if gettext() is the best way doing this? Most articles date back to even 2002, isn't there a new way maybe in PHP 5.2?
Also I read that you have to reboot the server when you make adjustments to the translations??
The intl extension uses the new ICU library but it's only available in PHP 5.3+
Yes, rebooting the server is a major issue which was a dealbraker for me. Also gettext's primary intention is to translate language strings, not substitute constants with text, whether that's good for you is for you to decide (i.e. text replacement is 'A dog is brown'=>'Das hund ist braun' (I don't know German;), constant replacement is 'catalog_greeting'=>'Welcome to the catalog').
There are lots of alternative pure-PHP solutions that may work for you. I use a constant replacement scheme that I save in the database and create a separate serialized array for every language on each save, so fetching is extremely quick and the database format matters does not matter to performance. Works great, easy to setup (even from scratch), easy to maintain and extend.
I need to build a simple web-based data entry/editing tool - something that would let me avoid using MS Access for the task. Preferrably in PHP and something that would be support SQLite, foreign keys/references and field validation.
I've looked at the demos of Symfony and was not impressed with the user interface in the end. Are there any other frameworks/tools that can work for this?
Whilst not expressly web-based you could consider:
http://www.sqliteexpert.com/
The only ones I know of are:
http://phpsqliteadmin.sourceforge.net/
http://www.sqlitemanager.org/
There not to good looking but they may work for what you want.
I'd plug my own dynamic database CMS system, but I have a feeling you would need some modifications for what you want. Any reason speicifically you need SQLite instead of mySQL?
Here it is just in case... UltraPanel PRO
I have started to try out noSQL databases now and are currently testing out couchDB. Seems like a good solution, but I really get some headache when I follow available examples on how to create views (queries) to select documents from a database and sort them.
Everything I can find is regarding JavaScript and it would be great to take part of some examples for PHP since that is the language we will use.
So, how do I create views using PHP for couchDB?
As far as I know, the equivalent of the SQL language that would be used for a relationnal database is, for CouchDB, Javascript.
So, if you want to create some "query", or "view", you have to do it in that language : it's the one that's understood by CouchDb.
PHP and CouchDb are totally independant : the only thing is that :
PHP can send requests to CouchDb
and get results
But what happens on the CouchDb side is independant of your PHP script -- and there is no PHP on the CouchDb side.
The only way to filter results using PHP would be to :
Request more data from CouchDb than you need
And throw away, from PHP, what's not needed
But, obviously, that would not be an efficient solution...
Javascript is privileged as a CouchDB view server only because that's what's bundled with CouchDB. There are view server implementations for many other languages/runtimes, including PHP.
JavaScript (CouchDB native)
Common Lisp
PHP
Ruby (fork)
Python
couchdb-python
couchdb-pythonviews
Erlang
built-in view server
erlview
Clojure
Perl
Chicken Scheme
Coldfusion
Haskell
OCaml
I think you need to understand Javascript's stance in CouchDB. Javascript isn't a target language like PHP, Ruby, etc. Javascript is more equivalent to SQL here. The javascript is server-side and CouchDB itself actually executes it. This is what you use to do map/reduce and build views and such.
Try PHPillow man
Here's a very short introduction to it: http://www.catswhocode.com/blog/getting-started-with-couchdb-tutorial-a-beginners-guide
If you check out the SVN of PHPillow, there's more information in the 'docs' folder
I am building a website and it need to be in 7 languages?
I was wondering if there is a good practice can be applied to get multilingual php script?
Easy for me
Easy for the translators
Also what do you think , should I Store it in DB , XML or in PHP file?
There are plenty of options for storing translations:
TMX: A relatively new XML format for translations. Seems to be gaining in popularity.
Gettext is another open format for translations. Been the de-facto standard for a long time.
ini files - easy to edit, very simple format
PHP files (arrays) - easy to edit for PHP programmers, good performance
CSV format - relatively simple to use.
I'd suggest you use something like Zend_Translate which supports multiple adapters and provides a basic approach to embedding translations in your application.
Contrary to daddz I would recommend against using gettext in PHP:
The locale setting is per-process. This means that when you are working with a multithreaded apache or any other multithreaded webserver running PHP in-process, calling setlocale in one thread will affect the other threads.
Because you can't know which thread/process is handling which request, you'll run into awful problems with users intermittently getting the wrong locale.
The locale you set in PHP has influence on functions like printf or even strtotime. You will certainly get bit by "strange" number formats arriving in your backend code if you work with gettext/setlocale
Use any of the other solutions lined to by Eran or quickly do something yourself (PHP arrays work very nicely). Also use the intl-extension which will be in core PHP 5.3 for number and date formating and collation.
Using gettext on a web based solution over and over proved to be quite like opening the proverbial can of worms.
I'd suggest Gettext.
It's cross-platform, open-source, widely used and available for php: PHP Gettext
I have built multilingual CMS. All content was stored in a database, with main tables for common (not language specific values) and separate tables for the language specific content.
For instance, let us imagine storing products - we have a 'products' table (contains unique_id, date created, image urls etc etc) and a 'product_local' table (contains any language specific fields).
Using this method it is very easy to maintain content.
I have no experience on gettext so no comment on that topic, but I have built a few multi-lingual sites using the following methods:
METHOD 1
I wouldn't say my format is the best, just that it's effective. I've also used array. Depending on where the content is stored.
For example, I'll have an associative array of text with the indexes identifying which text:
$text['english']['welcome'] = "Welcome to my site. blah blah blah";
$text['english']['login'] = "Please enter your username and password to login";
And maybe set your language with a constant or config variable.
METHOD 2
I've built two sites with identical structures and back-ends but each one used a different database and were maintained separately: data_french, data_english.
You may find this article on the topic an interesting read:
http://cubicspot.blogspot.com/2011/12/cross-platform-multilingual-support-in.html
The author advocates a "lazy programmer" strategy - do it only if you need multilingual stuff - and seems to recommend the PHP array approach with IANA language codes. The article is kind of vague though.
Check this forum. I think you'd probably need a different approach if you have somebody helps you with translation.
Most efficient approach for multilingual PHP website