r/learnprogramming • • 11h 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

29 comments sorted by

3

u/Quantum-Bot 10h 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 10h ago

alright thanks, ill check out whats electron is about

1

u/DiodeInc 11h ago

In what language? For what platform?

0

u/LRandomDudeV 10h 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 10h 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 10h 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 10h 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 10h ago

want an app

1

u/DiodeInc 10h ago

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

1

u/LRandomDudeV 10h ago

yeah sounds fair to me. thanks for help

1

u/kutac56 10h 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 10h ago

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

1

u/rupertavery64 9h 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 7h ago

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

1

u/rupertavery64 6h 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.

1

u/LRandomDudeV 5h ago

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

1

u/rupertavery64 2h 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/BranchLatter4294 11h ago

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

1

u/LRandomDudeV 10h ago

pretty vague for a helpful answer ¬ ,¬

2

u/BranchLatter4294 10h 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.

-1

u/LRandomDudeV 10h 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/DragonfruitGrand5683 10h 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 10h 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 10h 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 10h 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 10h 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.

1

u/Ahmed_Hisham0 7h 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.

1

u/AdhesivenessFew8441 4h ago

Since you already know PHP and SQL, you do not have to rewrite anything. Two simple ways to make it feel like a real Windows app: 1) PHP Desktop, an open source project that bundles a small browser window with PHP built in. You drop your PHP files into its www folder, double click the exe, and your project opens in its own window, no server needed. 2) If you use Laravel, NativePHP does the same with more features. For the database, use SQLite instead of MySQL: it is a single file that ships with the app, so whoever downloads it does not have to install a database server. For the player itself, the HTML audio tag plus a little JavaScript for play, pause and next is enough, and PHP can scan a music folder and save the song list in SQLite. Then zip the folder or put it in a GitHub release so people can download it. That would make a nice graduation project.