By Sudhanshu Raheja
In: programming, software, technology, web, website
15 Jan 2010For the last few months, we have been working on creating our own PHP framework which can help us build applications quickly and safely. The result is called Generatrix and it is now hosted on Github.com
Here is a brief Introduction :
Generatrix is a MVC framework for PHP5 which is not inspired by existing frameworks but by our belief in Magic. Our idea was to create a framework, where everything works like magic. Some of the concepts might feel a little different if you’ve worked on other frameworks before, but trust me, whatever we have here, does work like magic.
If you find a bug, please fork this and fix it up. We would be indebited to you for life. If you need our help, let me know. If you are using this for a college project, apply to us and we will recruit you. If you are using this for a commercial project, you can either pay us $500 a year or send us a thank you email. We value each of them equally. If you think it sucks, or just want to get friendly, or want to buy us a beer, or want to talk business, or if you just want to spam us, you can drop us an email at contact@vxtindia.com.
There are a lot of features planned, but here is the list of features which are already working
One major problem with databases is that everytime you change something in the DB, it’s a pain to go and change the same details in the application as well. To fix this issue, we have created a file called databases.php which **automatically** creates classes for each table in your database so that you can directly start accessing them in your code. You would need the command line to do this. Once you are at the root of the app, you can do this – $ ./generatrix prepareModel . As soon as you do this, the code will check if a file called app/model/databases.php is already present. If it is, it will give you the instructions to delete it. If not, we will create a new file. So if the name of your table is cars, you would now have a class classed ‘cars’ which you can use as – $cars = new cars($this->getDb);
To create a new view, you don’t have to write any code. You can just type the following on the comand line – $ ./generatrix addPage test . It will automatically create two files – app/controllers/testController.php and
app/view/testView.php with the basic code already present.
In the file app/settings/config.json, you can set cache-pages as ‘true’ and set the time to any number of seconds. Now, all your pages will automatically be cached in a file for that duration.
In the occasional case that you need to cache database queries, you can set cache-db as ‘true’ in app/settings/config.json and your queries will start coming from a cache.
Instead of using the regular var_dump and print_r, which don’t display your objects and arrays properly, we have a new function called ‘display()’ which will highlight the error on the page so that you can see the problem clearly. You can also change the call to display_system() etc to show the message in a different way. You can also stop debugging for production servers, but mentioning ‘debug-values’ as ‘false’ in app/settings/config.json . All errors are automatically caught and displayed with the display_error() call. The values output are different depending on if you are viewing them on the browser or CLI ( or ‘\n’)
All URLs are automatically rewritten in Generatrix. By default a url like http://vxtindia.com/contacts/view would send the request to app/controllers/contactsController.php and call the funtion view() in that file. Once that gets executed, it will call app/views/contactsView.php and call the function view() there.
Since automatic URL rewriting is such a pain at times, we added a way to map your controllers and functions, so that you can choose which parameter in the url should be the controller and which should be the function that gets called automatically. You can do so by setting ‘use-catch-all’ to ‘true’ in app/settings/config.json and editing the file app/settings/mapping.php
Unluckily we can only access one database right now. In case you need to access it, all you have to do is enter the details in app/settings/config.json . There will only be one common database object, which will only get created when you make a call to the database. If you don’t, the object never initializes.
You can also use database prefixes, as we have used ‘cv_’ in the example. If you do that, your class names won’t show cv_ in the name. For example, if you are using Wordpress, and you want to access the wp_users table, you can set the ‘database-prefix’ value to ‘wp_’ and your class name would now only be ‘user’.
If you want to use any of the javascript libraries hosted by google, you can just enter the version number for that file in app/settings/config.json and that file will be loaded automatically. You can use this to load Jquery, JqueryUI, Prototype, Scriptalicious, MooTools, Dojo, SWFObject, YUI or EXT Core.
PHPMailer is included by default, so you can call it whenever you like without downloading and installing it!
Any url that can run in the browser can also work in CLI!! I know that’s way too cool. To give you an example, if you have your login page as http://vxtindia.com/user/login, you can see the exact same output on CLI by typing ./index.php user login . This works like a charm when you use **cronjobs**
All files in app/model, app/controllers, app/views and app/external are automatically included in the system. So you can call them without thinking twice.
Since only the view gets called automatically, you can break a page into subviews. You can reuse that subview in any of the views again.
The Controller has an option called is_html which if set to false means that you’re writing a JSON or XML response. In that case, it doesn’t try to include the DOCTYPE automatically. And well, this is the next point.
For all your pages, you can set the doctype automatically by mentioning it the file app/settings/config.json
We love Blueprint so much that we load it automatically in the code for each page. So you can just start typing class=’span-24′ and it will work. If your page width is not 950px, you can also edit the values in the file
public/style/generated.phpx . The .phpx extension is include in .htaccess so you don’t have to worry about it. You can just change the variable $total_width to whatever value you like and it should work!
A control is piece of code which contains HTML, CSS and JS for the complete part. You can include any control by simply calling $this->loadControl(). The most popular is going to be Table Control
Using javascript from datatables.net, we convert tables into searchable, paginated data tables as soon as you use the control ‘tables’ by calling $this->loadControl(’table’, …).
All calls to the database returns Associative Arrays. When you select, you get a new row from each new row in the database. When you insert you get the insert_id as the response (again in an array). We can also log the timing required for each database call, if you’re worried about your performance. Also doing simple selects, inserts, deletes are easier that you can imagine!
So you don’t have to download a new version everytime! You can use the class Curl in the system.
To export the complete database, you can just type the following on the command line – $ ./generatrix exportDb
Writing relative links is always a problem, so we have made sure that you don’t have to do that at all! To write the absolute url, you need to call the function href(’/user/login’) and the parameters are from the root of Generatrix and not of the server. Redirections works in a similar way. You only need to mention the path from the Generatrix root.
A function call to image($path, $height, $width), returns the path using timthumb.php. For example, I have an image at http://vxtindia.com/test/something/vercingetorix.gif, and I need to display it in size 50×50, we can go –
image(’/test/something/vercingetorix.gif’, 50, 50).
To include any external class in the code, just copy it to app/external and it will automatically be loaded. If you have a folder, you can move the folder to the external folder and write a file outside which access the values inside the new folder.
Want it? Get it here
Just got this in the email today from BigOye.com. This is a blog being run by Reliance Big Entertainment, but it seems the editorial team lost it somewhere.
Have you seen them do it before
In: entrepreneurship, jobs, movies
15 Aug 2009
If there is one production house that is on a roll, it’s got to be UTV.
Over the last few years, the have given us Kaminey, Dev.D, Oye Lucky! Lucky Oye!, Khosla Ka Ghosla, Bluffmaster, Swades, Parineeta, Rang De Basanti, Life in a Metro, Aamir. Their forthcoming flicks include Paan Singh Tomar, Peter Gaya Kaam Se, Alibaba Aur 41 Chor and Arjun – The Warrior Prince
It’s literally the complete list of the best movies to have released of late.
The facebook fan page of UTV has over 2355 fans and twitter account has 1928 followers, which is a little less when you consider that their valuation is at $321 million. UTV ‘Spotboy’, which got Dev.D into this world, had also made it to the US top 20 distributors in 2008.
But as they say, a company is only as good as the people driving it. So it’s not surprising that the UTV group as a whole was started by Ronnie Screwvala who is a self made entrepreneur with a story worth knowing. He created the first organised cable TV network in India around 1981, when he was just 19 years old. Soon he was into making advertisements, producing TV shows, and finally he managed to get into movies.
At age 28, Ronnie Screwvala started UTV Software Communications and just five years later they went public. Walt Disney currently owns 32.1 percent share in the company.
They also recently started Hungama TV, which became the most watched channel in it’s genre, and who gave us Shin Chan. They also acquired Indiagames last year, from entrepreneur Vishal Gondal.
Anyways, the whole point of the post is that I just heard that their Chief Creative Officer and the COO have resigned, and I have just been thinking if I should let them know if I am interested in the opening… What do you think?
I finally got a beta account for Gist and it looks really really awesome. Trust me!
The tipping point for Firefox and Ubuntu is finally here.
I have been an evangelist for Firefox and Ubuntu for quite a few years now. The obsession with Firefox started quite a long time ago, when I was in college. Linux too hit the right notes then, but Ubuntu itself came in later, specifically when I started Vercingetorix Technologies. The biggest reason was that when you work on the LAMP stack, you need everybody on the team to be comfortable with the operating system. And Ubuntu was just perfect.
There is always a time for each product when people decide that they need to stop using it. It is the tipping point, when markets start shifting to a new product and the market for the old one disappears.
After having successfully used them for years, this tipping point for Firefox and Ubuntu is finally here for us.
The reasons are many, though the biggest is that they didn’t evolve with time, or atleast as much as they should have.
Firefox can’t stop hogging memory, and at times takes up over 700MB of RAM. It has been completely ousted by Google Chrome, which has two things which Firefox could never do, and which now, I can’t live without
1. Each tab is a different process. So when it crashes, only one tab crashes. The rest of the pages are still up and running.
2. The memory consumption is negligible. The sum of the memory consumed by all tabs increases and decreases based on the number of tabs which are open.
There are other reasons, like the area being bigger and the inability to add plugins (which really make Firefox drag).
As a side effect, I have also stopped using Delicious. Firefox had an awesome plugin, which made it way too simple to add anything to Delicious. Chrome doesn’t give me that feature, but now I’m content with saving bookmarks right there on Chrome.
The reasons for getting over Ubuntu were slightly different.
The single biggest issue was that there is no good enough browser available for Linux. Firefox was the best browser available, but Firefox on Ubuntu is even worse that Firefox on Windows.
Also, the last version of Ubuntu that I liked was 7.10. They have had three different versions after that, but I just don’t see what value they have added, except a slightly better looking UI. (Though the UI still sucks compared to a Mac or Windows).
We have finally replaced all machines from Ubuntu to Windows 7. Microsoft gave the final blow to Ubuntu by starting the BizSpark program, which gives free access to all Microsoft programs. Google did their bit by making sure that Chrome doesn’t work well on Ubuntu.
Finally, the UI is beautiful. Maybe not as awesome as the Mac, but it’s definitely a huge improvement.
And in case you haven’t heard it yet, Windows 7 take up less memory on it’s own that Firefox with 10 tabs!!
We always knew that Adobe really needs to start supporting more platforms if they need to stay in the game, but now it turns out that Google is also saying it.
Check this out :

Another interesting point which comes up is that if this was because the server on which the Google Spider was running was not in the list of operating systems supported by Adobe.
If this was because of it, some companies are at a real disadvantage!
In: internet, programming, software, startup, svn, technology, tips
3 Jun 2009We finally managed to setup SVN to start sending us emails on each commit. I also wrote about it in more detail on the company blog.
If you’ve just started hosting svn on your server recently, you should take a look.
In: Google Apps, Mail, Postfix, slicehost, ubuntu
17 Feb 2009We just moved to SliceHost recently and have been trying to get the server up and running. Every thing was super cool, but getting outgoing email to start working was a bitch.
What happens is that our poor little sendmail tries to be smart and deliver as much mail internally as possible. So even though the email address is set up to be used via Google Apps, sendmail tries to relay it internally and gets a ‘User unknown’.
This was confirmed by peeping into /var/log/mail.log and setting up a simple script in php which called the mail function. The user was never found, because we were looking at the wrong place.
Since I wasn’t prepared to spend a good part of the day on this thing, I decided to look out for options. After looking at a number of options, I decided to go ahead with ‘postfix’.
Let me take you step by step through the procedure :
1. As always, aptitude is there to help us out, so first we install postfix
sudo aptitude install postfix
2. During the installation, remember to choose the ‘Internet site’ option (because that is what you are doing. Right?)
3. Now that installation is done, it’s time to tell postfix that the domain is set up on Google Apps and not on the server (Actually we only tell postfix that the domain is not on the server). In the file /etc/postfix/mail.cnf we change the following
mydestination = mydomain.com, localhost.mydomain.com, localhost
to
mydestination = localhost.mydomain.com, localhost
4. Once that is done, just quit and restart (using sudo reboot) and you’re done.
In case you run into issues with the above, or find out a way to run this with sendmail, do let me know.
In: movies
10 Feb 2009The masterpiece of our times.
Here is an unsettling picture from Bloomberg which shows how much the market capitalization of the major banks have shrunk in the last two years. (Click the link to view the full image)
Citibank and RBS look really bad, falling by almost 92.5% and 96.2%.
Interestingly, among this lot, HSBC has the maximum market cap these days, followed by JP Morgan and Sant ander.
Luckily market cap is not something startups have to worry about!
Gyaan Sutra is about entrepreneurship and technology. It is written and maintained by Sudhanshu Raheja, who is also the founder of Vercingetorix Technologies