Creating a multi user Chat application in core php - php

Hi Im building a User relationship management application in php, here in this application we would require a multi user chat application in php, since im new to chat based application if any one have a chat application in core php please do share with me if would be very helpfull

Probably not an exact answer to your question, but could be useful.
Building a multi-user chat system from scratch on bare PHP, is a lot of work. You might want to look into php frameworks that save you at least half of the work.
Have a look at Laravel Framework: https://laravel.com/docs/5.6
It can integrate 3rd party services, example Pusher(https://pusher.com/) to run a multiple channel chat.
There are a lot of tutorials on youtube.com or https://laracasts.com/ (Laravel dedicated resource center and forum) that can help you get a chat up and running within an hour or two.

Why don't you integrate socket.io in your application.

Related

Q: Backend for ReactJS

First of all I hope I'm allowed to ask such a broad question (first time doing so).
Ok so I'm very new to React & I need a project to work on so I thought I'd recreate my portfolio (currently created in laravel) as a react & react native app.
My questions are:
Would a Rest Api NETCORE backend be a good choice for react ?
My experience is more in ASPNET MVC than Core, should i just stick
with MVC API's for now (i've already started creating a NETCORE Api
for learning purposes)?
Would a php framework such as CodeIgniter be better for this kind of
job?
My main question is if this is a good approach? I'd like to have a basic backend (auth, news posts, portfolio items etc) and then continue building on my react apps.
I was thinking that by creating a Rest API backend it would save me a lot of trouble when trying to create a react app for PC,Android or whatever (same back-end, different client).
P.S: i'm going to host my API on Azure's free websites if its ASPNET or a shared hosting if its PHP, that is the reason for which im moving away from laravel (so laravel is a no-no).
P.S2: Firebase or other clouds (except Azure) are a no-go for me. I have access to lots of resources and i'd like to use them & not use free services like firebase or whatnot.
Just giving my 2 pence here, as this is really opinion based!
In terms of the backend, it's up to you, whatever you feel more comfortable with - but I would give a keen eye on the architecture of the backend system you build.
My choice would be to create a micro services based architecture where you create simple, atomic services which only deal within their domain. For example, you could create 'Common Services' - services which can be used as dependancies by other services (events, encryption, documents etc..) then create atomic services which deal with an aspect of your application such as User Service, Payment Service, Product Service, Basket Service etc..
The idea is simple, to create simple data driven CRUD services which are modular, atomic and reusable. I've found that learning new technology is great but understanding and learning good programming architecture is even more rewarding. You can structure data to make it the most efficient for you.
Once you have built a service, you could use services like Swagger UI to automate documentation and create testing suites for them. If you haven't used Swagger I throughly recommend it.
Implement testing for each service, and go through the whole lifecycle of software development. That will really go far in your portfolio.
Here are some articles relating to building microservices in ASP.NET Core
https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/data-driven-crud-microservice
Swagger
https://swagger.io/
As a side note, I do not develop in ASP nor any other microsoft stack - but the principle is the same
UPDATE
The issue with building monolithic applications is that the code base can get more and more complicated and huge as your app grows. Some advantages of Micorservices are:
Scalability
Fault Insolation
Eliminates long-term commitment to a single technology stack
Easier for developers to understand (and document)
My type of set up would be using Spring Boot (Java) and using Eureka Server - but you are into the MS Stack, but the link I've given you above shows how to create a basic CRUD microservice with Net Core. I would give that a go, and see how it goes, then you can move to CI/CD for Azure!
Moving on from just a simple CRUD API, you can introduce WS connections with event driven updates (server to client) rather than asking for new data.
An Architect that I once worked with (a genius guy) told me never to be too reliant on a 'Framework' - they're cool when they are doing well, but a great application should be flexible to change, so I wouldn't rely too much upon a 'framework' but that was just his opinion.
Try API Platform - dockerized, but deployable to php hosting (based on Symfony), generates react-admin based admin and optional web/mobile clients (IMHO the weakest parts of this project), openAPI (swagger) docs, easily usable with graphQL ... just try.
Building portfolio with Laravel isn't a good idea. Use Gatsby - you can use graphql (WordPress, contentfull) as a source, generate static site.

Adding REST API to existing PHP website

I'm using some open source code to launch a game. The game is old, around 11yrs. It is a tick based web based game. It's written in php and using MySQL. Basically I want to port this game to ios, instead of using uiwebview I want to build native controls.
I know that it's bad practice to communicate directly with MySQL from an ios app. So what I want to do is add a RESTful API. I'm new to this and have scoured google for answers, does anyone have any pointers of where to start when adding an API to an existing site? It's quite a complex structure.
Thanks.
Paul.
My suggestion is using a framework that is guided towards building an API. I use Slim Framework for my API back end and it's pretty easy to use. If you create a separate URL for this API or include directly into the PHP project as a class it could work.
Some tutorials to get you started are
Say Hello World with Slim
RESTful services with jQuery, PHP and the Slim Framework
Writing a RESTful Web Service with Slim
Hope this helps,
Wes

Joomla application interaction with mobile application

I am currently working on a project involving a Joomla application and a Mobile application. I so far have created both applications and now I want to link the Mobile application to the same database as is used within the joomla application.
I have done some research and it seems that to directly connect to the database is not the best option due to security reasons etc... The use of a web service is recommended.
My understanding of this is this is say for example I have a "player" table in my database which consists of players to output these players via the joomla application in an XML or JSON format which can then be accessed by the mobile application and parsed.
I am curious as to how to go about creating this webservice within the joomla application/framework?
There is a lot of talk in the Joomla world about integrating this into the core in some way. There is even a web services working group, so this is going to be getting easier in the future.
In terms of something to work with, the best code that I have seen is still very sparse, but it could be a good start: https://github.com/techjoomla/Joomla-REST-API. This is by Tech Joomla. I haven't actually played with this code, but it looks to be implementing a REST api, which is probably what you want.
For more code, you may want to get in touch with the working group and see if they have beta code that you could help test and improve for your situation. http://docs.joomla.org/Web_Services_Working_Group

How to create an API-centric application (more specifically: for HMVC in CodeIgniter)

Background:
I am working on a web application, that I plan to launch with iPhone and Android versions in the near future, and I have some questions about developing an API for use by the different front-ends.
I Started with This:
I was reading this TutsPlus tutorial, which talks about creating an API-centric web application, meaning that all of your browser calls and smartphone app calls are routed through the API.
What especially got me excited, was this statement in the tutorial from Twitter:
One of the most important architectural changes is that Twitter.com is now a client of our own API. It fetches data from the same endpoints that the mobile site, our apps for iPhone, iPad, Android, and every third-party application use.
The above statement reflects, what I would ideally like to create.
Then I Saw This:
I found this TutsPlus tutorial, which talks about, how to build a REST API for CodeIgniter. This was good, because I am developing my application in CodeIgniter, using the Modular Extensions plugin - HMVC, and I thought it would be perfect for my purposes.
The only thing, that I'm somewhat lost in, is the way Phil Sturgeon seems to suggest to create the API. He suggests to have all of your front-end code modules completed and then create an API for each of the modules in their respective directories (not necessarily in that order). This would be fine if I didn't want it to be API-centric.
And I Want to Know How to Do This:
How should I proceed to get a blend of both tutorials:
API-centric application that can be used by a browser application as well as separate mobile applications
REST API for CodeIgniter (with HMVC modules)
Should I:
Just follow the API-centric tutorial and try to tailor it to my needs?
Follow the CodeIgniter-specific tutorial and use Phil Sturgeon's advice for how to implement it with HVMC?
A combination of both?
Neither?
Take a look at Eating your own Dogfood by Nick Jackson. These are slides from CICONF 2012 where he details how this all works.
Building your API first is a great idea, then your application can use the API to fetch the data itself. This is of course a little slower as you're adding a HTTP request on data, but locally its not too bad and if you use HMVC to make the request it's even quicker.
In the tutorial I didn't get into HMVC because it's an extra subject, but it can be awesome for adding modular API's. In some simple applications I just make a /api folder like the tutorial suggested but PyroCMS Professional has an API module and a sexy route to allow modular API stuff:
$route['api/([a-zA-Z0-9_-]+)/(:any)'] = '$1/api/$2';
$route['api/([a-zA-Z0-9_-]+)'] = '$1/api/index';
This means I can have a "api.php" controller in every module and still use the /api/controller/method syntax or even /api/controller if you have function index_get().
I would strongly suggest you grab PyroCMS Professional for this feature. Yep you gotta pay, but it handles user key generation, authorisation, logging, etc all out of the box and handles your website too.

Android app 101: how do I sync web contents to the app? just starting building applications

I'm trying to build my own android application, and I was wondering if someone can direct me or help me find a tutorial on what to do to get contents between the two. I've been teaching myself php and web building and now I'm trying to build an android app.
But I have no idea as to how to sync the two pieces together? Say if I wanted to update some contents on my php page, how would it be updated to my android app? I'm also beginner at java, but I do have ambition to learning these things.
Thank you in advance fellow members.
ps I've been messing around with eclipse and the android platform.
I don't know if you wanted to write it from scratch or find some sort of library. I've also just started android development and I stumbled across a project called openmobster.
http://code.google.com/p/openmobster/
It's a library for integrating mobile applications with web based services. They have tutorials and documentation in the wiki section. For example: http://code.google.com/p/openmobster/wiki/AndroidSyncApp
If you were interested in writing something from scratch you should be able to browse the source to see some of the things they are doing.

Categories