Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
What technology to use for chat? I would like to create an open connection.
When I put a new message to the database. I want to automatically without using the timer and making loops came a new message to the browser.
I have Linux web hosting with a MySQL database.
I tried to make retrieving new messages and use the timer. Every three seconds I am using Ajax retrieve data. This solution seems to me inefficient, so looking for others.
PHP is a server-side scripting language, which means all the PHP is processed before the page even loads. In order to generate a chat-like environment, you would need to use Javascript to establish an open connection to the back-end (the PHP part). There are many methods to doing this, including polling (timers) and sockets (much more complicated).
The best way I know of to handle a chat-like service using Javascript would be to check out Node.js and its capabilities, specifically demonstrated as a chat room here: http://chat.nodejs.org/.
The problem with NodeJS and persistent connections in general is that most cheap hosting providers don't allow you to have persistent connections open. You would need to pony up for a higher-cost dedicated server. There are, I believe, hosts that specifically allow NodeJS-type services in their environments, but I don't know of any off the top of my head.
You might need to implement COMET technology. It allows to make long pooling requests. When one request is done you can start another one. In COMET connection is always open.
In PHP you can do that creating infinity loop, while(true) for example and break connection when you need.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm considering building a simple game with PHP as its backbone, but rather than doing a bunch of post redirects like classic web games this one will involve more immediate responses through ajax. In order to achieve what I want though, I think I'll want to store some information (locations of players, for instance) in server memory as opposed to a database. Should I use a caching library like Memcached or APA for this, or is there an alternative that will work better?
Memcached is a great tool for caching data because it's very fast and has a simple interface, but if the data you want to store needs to slightly more permanent and you cannot recreate it if it is lost, I would recommend something more durable. I have used Membase (same interface as memcached, but is persisted to disk eventually) and Redis (more robust interface including lists and a whole lot more).
Bottom line, if it's information you have stored in some other place but you just want to keep fast access to it, memcached is great. If you want something lighter than SQL but it will be the only place the information is stored, try some other NoSQL solution.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm trying to simulate a web browser in order to log into a secure site, where the site's backend seems to be written in some mix of PHP and ASP.NET, and retrieve some user details.
In order to fit my own project, the simulation results (i.e. the user details) must be returned to a PHP script for processing.
So far I've been working with CURL in PHP to do this, and realised that the site is far too complicated to use CURL effectively, and this method is far too slow to develop. What I would like is some sort of browser simulator that can:
Execute JavaScript
Submit forms
Click links
Handles cookies
Uses ASP.NET postbacks
Can access the DOM
Basically something that behaves exactly like a real browser, and can return the page source to me.
I've explored the Snoopy class in PHP and Capybara in Ruby. If I don't get any better options I will be forced to implement with one of these.
You have two options:
Use a headless browser. This is basically browser without any graphical output, which can be controlled via. code. You can check out Selenium and PhantomJS, there probably exists bindings for your language of choice.
Reverse their site. Do the login flow and actions needed to get to the resource you need, and look at the network traffic, for example with Chrome's developer tools. Look at the requests, headers and form data needed for the endpoints in question and emulate that in the code.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
We are currently moving a lot of our code to use the api we've developed instead of making sql calls from our php. There will be a lot of functionality to test once this happens. I was wondering if you know of a good plugin or software to use to track and replicate and action (such as registering a user, the logging in, posting a comment, etc). I know there is software like selenium, but I've heard that it would be more of a hassle to setup than it's worth (for what we need it for).
I basically want to create a script of my actions on our stable build, then run that script on the build that is using our newly implemented api build that uses a different database, then come the two databases to make sure they have the same data.
Any suggestions would be great. There has to be a chrome plugin or something, but I haven't been be able to find it after a few hours of searching.
If these are web service calls to your API, you can use curl (on the command line or within PHP) or even Guzzle as it's just an HTTP Client for communicating with web services. What you are describing is testing your app, which is common. There is nothing trivial or easy about full test coverage so prepare to spend some time setting this up and working out the kinks.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Imagine a canvas paint tool where you can draw and paint on a website, but like a chat application, what you draw immediately shows up on your friend's canvas as well. WebSockets would be more that perfect for this. But since my website is being hosted by a web hotel that doesn't support JavaScript on the server, WebSockets is not an option (if I understood it correctly). Is there any other way I could build it - that almost keeps the efficiency that WebSockets provide? Or is my only good solution to host my web site on a server that let's me run JavaScript, (suck as note.js)?
This is what you are looking for http://tutorialzine.com/2012/08/nodejs-drawing-game/
The next best solution for sharing the canvas data in real-time, would be ajax long polling. Simply put, the client makes an ajax request to the server, if the server has fresh canvas data it returns the data, otherwise it keeps the HTTP request open until it has new data to return. Once data is returned, the process is repeated.
Since we are using standard HTTP requests, this wont be as efficient as web-sockets, as every HTTP request carries a bunch of headers which are not needed.
More on long polling - http://en.wikipedia.org/wiki/Comet_%28programming%29
I should add, WebSockets is not specific to NodeJs. WebSockets is a protocol which can be implemented in any language. There are libraries available for using WebSockets in a variety of different languages, including PHP, which I assume your server supports.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
The site that I am working on creates user sites like (domain.com/user). We want to show the users some web traffic statistics relevant to their own site, like how many views from facebook, twitter etc. Can you guys please recommend a solution which we can integrate into our PHP/MySQL based system? Or is it better to build one inside the system ourselves using mangoDB or something similar?
Any pointers would be appreciated.
For preference, unless you are using SSL, I would recommend implementing the sites as user.example.com/ rather than domain.com/user - it's much easier to configure your webserver to write seeprate log files / most off the shelf web analytics packages will split a log file from multiple vhosts into reports per vhost.
There's lots of tools available off the shelf - piwik, awstats, webalizer, analog
Google analytics is amazingly good value compared to most commercial offerings.
If you need to persist with your current naming schema, then consider using a too which relies on page tagging rather than log analysis.
Or is it better to build one inside the system ourselves using mangoDB or something similar?
I'd suggest that's very much a last resort - if you can't find what you need, then I'd recommend forking one of the open source packages.