Ratchet & Websockets - Can not get anything working - php

So I am fairly new to PHP and websockets and server management in general. But have been tasked with designing a web-app and have determined that the best way to implement this is with websockets. So I found ratchet. And began trying to get it to work. I have a linuxbox with apache already setup, and created a new directory in the webroot and began Ratchet's tutorial. However no matter what I did I could not get even the in-line telnet part working.
I have a composer.phar, I have their script within my composer.json, I followed their instructions for installing ratchet. however when I run the php chat_server.php command it doesn't seem to do anything. The tutorial states that it should take control of the console, and as I saw in a video tutorial it does.
So my ultimate question is - what is causing this not to run properly? Is it a bad installation (Did I mess up installing somewhere or just not install something that is required but was not explicitly stated?) all the code is identical to what is documented here http://socketo.me/docs/hello-world

Some questions when ratchet is not functioning while setting it up.
Is the php process (#php chat_server.php) open?
Are you telnetting from another cli?
can you check if the port on which the chat server should be running is allocated?(#netstat -pln)
Is the zmq library added to the apache modules? (Probably your problem)
If the above aren't working you might try to check if some firewall is blocking the connection internally.
I would suggest starting from a clean machine to execute all set up steps.

Related

Php java bridge Error : the procedure entry point php set error handling could not be located in dynamic link library C:\xampp\php\ext\php_java.dll

Integrating PHP java bridge, facing some issue while restarting Apache server as showing error:
The procedure entry point php set error handling could not be located in dynamic link library C:\xampp\php\ext\php_java.dll
I made the changes outlined below in my php.ini file and copied JavaBridge.jar and php_java.dll in C:\xampp\php\ext.
extension=php_java.dll
[java]
java.java_home = "C:\Program Files\Java\jdk1.8.0_131\bin"
java.java = "C:\Program Files\Java\jdk1.8.0_131\bin\javaw.exe"
java.class.path = "C:\xampp\php\ext\JavaBridge.jar"
java.library.path = "C:\xampp\php\ext"
java.log_level =2
Specific to your question:
First of all, the javabridge communication is not handled anymore by a php extension (I mean the php_java.dll or java.so).
So you simply don't need it, you can completly remove the "extension=php_java.dll" as this has been replaced by a pure php implementation known as the Java.inc client (or alternatively the soluble-japha client).
I believe you use a very old documentation... So don't spend too much time in this direction because you'll probably won't have support.
But if you want to work with the javabridge, just remember you'll have to install both:
a Java server that will expose the Java virtual machine on a network port (standalone or deployed on Tomcat)
a PHP client library on the PHP side that will establish communication with the server (Java.inc or soluble-japha)
I suggest you to read the docs on the official php-java-bridge website to get some insights about installation (or alternatively some docs for the unofficial soluble-japha project, they work pretty much the same way).
And first ensure, the php-java-bridge server is sucessfully running. The php-java-bridge files can be downloaded either:
Option 1: The war file (tomcat only) is here
Option 2: Individual files for cli/standalone server are here
Once it works, try to connect from PHP.
You'll probably face a lot of problems at first run, but from there it will be easier to answer your questions.
Good luck

Running PHP WebSocket on Ubuntu

Introduction
Before getting started with the actual question, I’d like to make a notice of being an extreme beginner to the world of web sockets using PHP. As a matter of fact, I’m still trying to grasp the very basics of it. I do however have lots of experience with sockets overall, from languages such as Java.
Upon doing my research, I stumbled upon the tutorial from PHP builder, whereas I think myself to having learned how to set socket connections up using this simple library.
Problem
Unto the problem we go. For a development server, I have chosen to go with XAMPP—it’ss sort of stayed with me from my Windows days, many years ago. At this very moment, I am using the terminal UI for XAMPP in Ubuntu—meaning, I launch the XAMPP server and then do a killall should I ever wish to close it.
In the tutorial mentioned above, you enter this information into your PHP document where you keep your server socket:
$server = new Server('192.168.0.8', '8000');
The Server class being a class extended by the WebSocketServer provided in the aforementioned library. You’re then supposed to run the PHP server socket using (with the dollar sign symbolizing terminal input):
$ php -q serversocket.php
It was suggested somewhere else on Stackoverflow that you run the server socket with the -f flag instead, but both of them—instead of starting the server socket—prints out the file contents in the terminal.
The PHP I’m using (to attempt running the server socket) is the one you get from running (on Ubuntu):
$ sudo apt-get install php
I’d assume this to be the regular version of PHP.
I’m honestly probably just being a huge moron, but truly do need help to solve this problem. Have I missed something?
The problem that was occurring at the time was the PHP code being displayed as raw data in the terminal whenever run. I was using short opening tags at the time <? and did have them enabled in the configuration.
I did however, resolve the issue, by rewriting the code to use the full opening PHP tags <?php. Perhaps there was more things to configure, maybe the version of PHP I was using was broken. Who knows?

Laravel 5 Heroku Local doesn't work

I've successfully deployed the Laravel application to Heroku.
It works online.
But when I try to run "heroku local" I get:
vendor/bin/heroku-php-apache2: No such file or directory
Which makes sense, since looking into "vendor/bin", the only thing listed is:
psysh -> ../psy/psysh/bin/psysh
So, where's my heroku-php-apache or how do I fix this?
You should have these lines in your composer.json
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
be sure to run composer update after you add them.
After extensive research, trial and error and talking to the Heroku Support team, I found out that, although Slow Loris's answer was a part of the process, the following answer was given to me by Heroku's Support:
To cut a long story short, heroku local is not officially supported for PHP >applications. The reason is that unlike all the other languages we support on the >platform, PHP has no web servers written in userland. Instead, we use PHP-FPM >together with Apache or Nginx, and the boot scripts (vendor/bin/heroku-(php|hhvm)-(apache2|nginx)) dynamically inject the correct configuration for port >binding and the FastCGI comms sockets.
This works with vanilla PHP and Apache builds, provided that:
1) the current user has all the correct permissions (in your case, >/var/log/apache2/ isn't writable);
2) the correct proxy modules are loaded in the main httpd.conf;
3) the main httpd.conf doesn't bind to a port at all, or at least not to one >under 1024 (which are reserved for superusers).
The main config also needs to be handled by each user on their own, because >sometimes, the modules to be loaded are in libexec/, sometimes in >lib/apache2/modules/, and so forth. Just too many variations; otherwise, we could >ship a full Apache config to users and the experience would be much better.
But the problems don't end there. FPM does not work at all on Windows, and on >most Linux systems, httpd is not a command that works; instead, apache2ctl >handles starting and stopping, and thus, running a server in the foreground is >not possible. In the end, there are simply too many possible permutations in >system configs that make it impossible to ensure every user has a great >experience.
It's simply the current reality in PHP land. Ruby, Python, Node, Java all have >web servers that are written in each respective language, and you don't need >external servers. Which also makes it possible to stream file uploads, handle web >socket upgrades, and so forth. Maybe with PHP 7 we'll see something like that >emerge soon (in PHP 5 it's simply not feasible at all, because a fatal error >kills the engine, so your web server would be gone too).
I know this question is a little dated but I recently deployed a heroku app for the first time and was unable to get heroku local to work for me. I'm on the current branch of Laravel which is 5.8, I am also on Windows 10 using VS Code. I searched all over trying to rectify this issue and could not get it to work no matter what.
I did come up with a solution to be able to work on this locally with only a few lines in terminal.
In VS Code, I used gitbash terminal, once in my heroku project folder composer require laravel/homestead --dev, once that is complete, then we need to install homestead, vendor/bin/homestead make, and then once that is complete, simply run vagrant up and your app will be accessible through localhost:8000.
Docs - https://laravel.com/docs/5.8/homestead
Hope this helps someone!

NewRelic install on centos and cpanel

I'm trying to install NewRelic on my website, I use PHP, cPanel(VPS/dedicated) and Centos (64bit) for my server, I've installed the server monitoring part right on my server but when I try to install the 'app' part on my server I can't get that to install, I followed the instruction links http://newrelic.com/docs/php/new-relic-for-php
but to no success, has anyone got any ideas as to why this maybe? I have restared httpd and appache multiple times and given it some time to propogate etc..
The problem of this is having WHM installed and many PHP services installed, you should try this guide I found:
New Relic for PHP w/cPanel
We have few dedicated servers on HostGator. Few months back we had installed "NewRelic" on our server for monitoring, later we started having issues and here is what HostGator Tech Team said
"While it's possible to configure a cPanel server to use a non-cPanel
PHP version, it's complicated to configure and we will not support it
or set it up. PHP gets compiled from source by cPanel normally and it
should be left this way, as it interacts with a number of other
components on the server in complicated ways, as you found out today.
We recommend completely removing the custom "Newrelic" repository as
well as the packages it installed in order to avoid further
compatibility problems."
and here is what "NewRelic" team said
"I wasn't trying to suggest that Hostgator's assertion was wrong. I
was just trying to figure out which instructions to go over with you."
Make sure to check compatibility before installing it. Installation instruction can be found at http://www.networkredux.com/answers/view/Hosting/Control_Panels/WHM/cPanel/162
New Relic Needs to document this cpanel compatibility better, I know it's my fault for not researching but while using a hostgator dedicated server with cpanel/whm I got new relic up and running. . then my server became a huge mess if improperly configured files and a few days of reading and learning to get it straightened out - I understand my fault entirely but a big ass CPANEL/WHM <- CAREFULL sign might have helped :P

Best PHP download to keep all my options open?

In the past, I used WAMPserver on windows to parse PHP for me. This is a pre-configured package, focussed on working with MySQL.
When I tried to run PostgreSQL, I got error messages that said that my version of PHP wasn't compiled to work with PostgreSQL.
So, I've recently uninstalled WAMP and every associated with it. I've downloaded Apache 2.2.11 with openSSL, installed as admin(you know, run the command prompt as administrator, cd to the directory where the download was done and have it executed, so the install was done as admin).
That's that. I now have Apache installed, "it works" shows up, so I'm that far.
Now I'm wondering, do I download the exe and install, or the zip, or something else.
What is the best thing to do to make sure that the PHP on my system can handle everything I can ever throw at it?
Also, PHP first, or MySQL/Postgre first.
And lastly, what about PEAR? I need PEAR installed, which isn't standard on Windows. I'm guessing the pear.bat file in the PHP downloads will do that for me?
EDIT: I see one close vote, yet no comment as to why. It makes me wonder how people who are so lazy and rude got to have somany points.
I would recommend downloading the zip package, as configuring php is not really that difficult, and it allows you to add features as needed.
As for whether first to install php or MySQL/PostgreSQL, - it does not really matter. You can install them in any order.
Your guess regarding PEAR is quite correct
i haven't used wamp before, so i can't comment on that
i do however use xampp which sounds very similar
in xampp if i want to enable postgres support i edit the php.ini file and uncomment the postgres section of the ini file, same with any of the extensions that i need
perhaps this might be an alternative you can try if you get stuck
There are many ways to setup a HTTP server/PHP/database machine. Sometimes the behaviour of your development setup will differ from the live server's.
I would recommend finding out the setup your web host is using, then getting a vmware appliance image that fits that as close as possible and get any additional software using it's package manager (which is easier that installing stuff on Windows).
Setup a file sharing link between the VM and the host, make sure you can view the VM's port 80 in a browser running in your host OS and you're set.

Categories