Welcome Guest, Not a member yet? Register   Sign In
How MVC in twitter working?
#1

[eluser]Dinesh Viswanath[/eluser]
Hello,

I’m quite new to CI. I would like to know how MVC concept in twitter working? May be my question seems to be silly but Pls help me out.

Twitter’s URL (which uses MVC framework) looks like www.twitter.com/dineshviswanath
Dineshviswanath is the user name. It implies me that new Controller has been started when user registering in twitter.
1. My question is that can we create controller at runtime dynamically in Codeigniter? If so how..?
Thanks in Advance
#2

[eluser]Colin Williams[/eluser]
They likely have a Status controller, and when you hit twitter.com/username, perhaps it's routed to /status/index/username. In fact, when you look at their RSS feeds, this is basically what you see: http://twitter.com/statuses/user_timeline/14133565.rss but instead of "index" they use "user_timeline"

Thinking of "creating controller dynamically at runtime" is a bizarrely complicated way to look at something as simple as routing. Dynamic routing, not dynamic controller creation.
#3

[eluser]TheFuzzy0ne[/eluser]
A simple route to pass the username to a specific controller should do exactly what you want.
#4

[eluser]Dinesh Viswanath[/eluser]
Thank you very much for your Support.. @Colin Williams @TheFuzzy0ne. I had good time in CI forum
#5

[eluser]Dam1an[/eluser]
So you plan on building a twitter clone/competitior?
One thing to know is, Twitter doesn't use a normalised database schema, as it just wouldn't scale
Instead, it has 26 buckets (one for each letter of the alphabet) and you get put in the buckets which matches the start of your username.
Then any tweets which you follow get placed into the bucket, so when you view your feed, it just picks everything from one location, instead of doing loads of SQL queries which would take forever.

What this does mean, is there's a lot of data duplication, which is frowned upon with RDBMS, but acceptable in the cloud
#6

[eluser]xwero[/eluser]
The problem with a one segment url that can be anything is that you have to add all the controllers that also can be called using a single segment.
Code:
$route['(shop|blog)(.*)'] = '$1$2'; // example of a few controllers that can have a single segment url
$route['([a-zA-Z0-9_\-]+)'] = 'users/profile/$1';
The username segment is best limited to the constraints of the username input, for example if the username has to be at least 4 characters the regex would be ([a-zA-Z0-9_\-]{4,}). This cuts down the checks for none existing usernames.
#7

[eluser]xwero[/eluser]
Dam1an it doesn't need to be a twitter cloon, it can be any app/site where profiles can be viewed by surfers.
#8

[eluser]Dam1an[/eluser]
[quote author="xwero" date="1240502940"]Dam1an it doesn't need to be a twitter cloon, it can be any app/site where profiles can be viewed by surfers.[/quote]

I know it doesn't have to be a twitter clone, but seeing as twitter was explicitly used in the example, I assumed thats the direction it was heading
#9

[eluser]xwero[/eluser]
I think people are always going to want to make a twitter clone but i guess not many want to use the underlying code and data organization as the site did suffer/suffers from a lot of downtime.
#10

[eluser]Dam1an[/eluser]
I think part of the problem with twitter is, it ended up becoming something it wasn't meant to be.
The original architecture, was much like a CMS (thats the period where downtime was common) buthas since changed to the strcture I mentioned earlier (and is now much more relaible)

Anyway, I seem to be going off track




Theme © iAndrew 2016 - Forum software by © MyBB