r/learnprogramming • • 4d ago

Help needed How to i turn my code into app?

I want to make a simple music player app for my school project, but they only thought us how to make stuff in web, so i want to do something more unique for the graduation project. I dont need any fancy app hosting, just a way i can download my code and use it as an app

ill be mainly using php, sql and css

0 Upvotes

32 comments sorted by

7

u/Quantum-Bot 4d ago

You can run your website locally just by opening up your HTML file like a document.

If you want to package it as an exe I would look at Electron.js. This might be a little involved for a school project though.

Your third option is to just rewrite your project in a native language. It’s not that hard to learn a new programming language after learning your first one. Switching programming languages is less like switching from English to French and more like switching from PC to Mac.

1

u/LRandomDudeV 4d ago

alright thanks, ill check out whats electron is about

2

u/kutac56 4d ago

Be a little more specific. What languages is it in? What type of app do you want (web app or normal app)?

1

u/LRandomDudeV 4d ago

i will mainly use php and css. and i just want is as regular downloadable app

2

u/BranchLatter4294 4d ago

Pick a language. Write your app. Run your app.

1

u/LRandomDudeV 4d ago

pretty vague for a helpful answer ¬ ,¬

4

u/BranchLatter4294 4d ago

It was a vague question. You didn't say what language you want to use, what libraries you need, whether it had to be cross platform, what type of presentation layer, etc.... None of the very basic questions that would help answer. Just do a bit of research and if you have specific questions, let us know.

-4

u/LRandomDudeV 4d ago

so theres this thing like asking for clarification like the person above did, maybe you can try doing that in the future

1

u/DiodeInc 4d ago

In what language? For what platform?

0

u/LRandomDudeV 4d ago

i suppose main thing will be in php + css, since i need to work with databases mainly, and it will be for windows

1

u/DiodeInc 4d ago

Just make the script and be done with it. Upload it to GitHub. Now it's hosted and can be downloaded

0

u/LRandomDudeV 4d ago

never thought about github that it could host websites like that, thanks for letting me know lol. And do you know any good tutorials on that topic?

1

u/DiodeInc 4d ago

Do you want a website or an app? GitHub cannot host any server side applications, only serving HTML/CSS and client side JS.

1

u/LRandomDudeV 4d ago

want an app

1

u/DiodeInc 4d ago

GitHub can host static websites. It can also host code and app downloads, your app should be open source then.

1

u/LRandomDudeV 4d ago

yeah sounds fair to me. thanks for help

1

u/rupertavery64 4d ago

The short answer is, with php and sql, you can"t.

If you make a web page in php, it is probably running on some php server like IIS, plus you have the data on a sql database.

Those aren't exactly desktop application frameworks.

The most direct way to make a desktop application is to use a language that has first party support for desktop.

If Windows, the easiest would be C# and WPF, or Avalonia. With linux you would use C/C++ and something like Qt, which I wouldn't call easy.

Basically you need a language that complies to native code that runs directly in your OS.

There are other options like Electron (which you write the UI part as a webpage, but basically you package an entire web browser in your app) and probably Python, but the end user has to have python installed.

1

u/LRandomDudeV 4d ago

well this surely is the most helpful reply ive gotten, thanks a lot!

1

u/rupertavery64 4d ago

You're welcome.

Basically, you have the language, which is how you write code. In reality it can be any language.

But then you also need a GUI framework, which is essentially a library that abstracts the UI rendering stuff (drawing the window, drawing the buttons, styling and theming the buttons, handling button clicks).

This can be tied to a language and an OS (like WPF), since each OS has a different way of doing UI stuff.

Some frameworks like Qt are built to support multiple OSes and multiple languages via "bindings", which basically allow you to call the library functions usually written in C through a wrapper for the language you are using, like Python.

So writing a desktop app can be pretty daunting if you want to support multiple OSes, which is why Electron was built. It's basically a browser being packed into the application, which is why an app that uses Electron will be like 300mb minimum and use a lot of memory.

Since you are using php, you are writing script that gets loaded by the php interpreter / compiler. This is usually a module that is part of a web server. So you need a web server like IIS installed, AND a browser to view the page that the php code will render when you send a request, plus you add in a database service. So there are at least 3 programs running to make your page appear.

A desktop application is just one program, running code and telling the OS directly how to draw stuff in a window provided by the OS. The OS sends "messages" to the window, like "the mouse moved over x,y", "the user pressed key A while this window / control has focus" and the UI framework takes all that and translates it into however the library decides to expose those events to the user. Meanwhile it runs an infinite loop to capture those events and update the screen when necessary. A lot of that stuff is usually hidden from the programmer in many frameworks.

If you've ever written a web page that does all of that stuff, well, the browser is just a desktop application that uses HTML to draw stuff to the screen in it's own way. It handles window events and passes them into the javascript engine so you can handle them in your program. Every time you scroll or change something on the page, type text, the browser is updating the state of the DOM, rerendering stuff and redrawing the window.

If you are writing something like a music player where you modify and store a playlist, you would probably use an embedded database like SQLite if you need to persist (store) things after you close the app. An embedded database is basically a library you load that does database stuff to a file directly without the need for a separate server. It's usually a lot less capable than a full-blown database server.

Either that, or just write data to a file, which is called serialization / deserialization.

2

u/LRandomDudeV 4d ago

you know, reading this i might want to stick to regular browser stuff if i want to graduate 😭

1

u/rupertavery64 3d ago

I may be complicating it a little bit. With enough time you can make a music player. You will need to lean on libraries to play music as unlike the browser which is a media engine as well, desktop apps are pretty bare bones. At any rate good luck with your studies!

1

u/Aggressive_Ad_5454 3d ago

Php desktop is basically Electron for php.

2

u/Ahmed_Hisham0 4d ago

php needs a server to run, so "download and double click" isn't going to work on its own. two ways around it for a school project.

the cheap one is to make it a PWA. the site stays a site, but the browser can install it to the desktop and it runs in its own window offline-ish. no packaging, works on windows and mac, and it looks good in a demo.

the other is phpdesktop, which wraps php plus a small browser into a single exe. it's old and fiddly on mac, but it does produce a real file you can hand in.

for a music player, the PWA is the honest answer. pick it before you write much, because retrofitting it later is annoying.

2

u/Murlock_Holmes 2d ago

You didn’t mention HTML or JavaScript, which are both things you need to know for web apps (which is what PHP is used for).

I’d recommend doing an easy index.html, put all of the JavaScript in <script> tags, and then sample music you can play. No SQL or PHP needed.

I do not believe you can (legally) create a music player that streams the music from another source, so local files will be best for this.

1

u/DragonfruitGrand5683 4d ago

You can make it in HTML, CSS, JavaScript. If you want it on desktop you can install it as a progressive web app.

1

u/Sea_Athlete1378 4d ago

You can just host it locally? Npm run dev, run through maven or whatever builder/language you're using and you're there no?

1

u/Feeling_Photograph_5 4d ago

You can use electron with a wrapper for PHP, since that is what you say you're using in another answer. That will get you an app you can download onto a laptop. 

If you want to make it work on a phone you might need to refactor the app to Flutter and Dart, but it is possible to download an app built that way directly onto your device without going through the App store. 

1

u/betarage 4d ago

For andriod apps you should probably learn kotlin or maybe dart making ios apps is harder. you can also just make a web page and save it as a html file and you can use it on your phone and pc.

1

u/Correct_Rain_9438 4d ago

Heads up on GitHub Pages. GitHub describes it as a static site host for HTML, CSS and JavaScript files, so a PHP and SQL project won't run there. It's fine for storing and sharing the code, but not for running the app.

0

u/BlindTeemo 3d ago

Try using Angular and then host it on Github pages. Works well for simple apps, and feels just like a real mobile app.