Create Web App
Note
To create a web app, you need an installation of the MATLAB® Compiler™ product.
To create a web app, you must first use MATLAB App Designer to design the app. Then, package it using the Web App
Compiler app or the compiler.build.webAppArchive
(MATLAB Compiler) function.
Create App Using App Designer
Before you can package and then deploy a web app, you need to create an app using MATLAB App Designer. For more information, see Create and Run a Simple App Using App Designer (MATLAB).
Create Web App Using Web App Compiler App
Build a web app using the Web App Compiler app. Alternatively, if you want to create a web app from the MATLAB command window using a programmatic approach, see Create Web App Using compiler.build.webAppArchive (MATLAB Compiler).
To open the app, on the Apps tab, expand the Apps gallery by clicking the drop down arrow. In the Application Deployment section, click Web App Compiler.
You can also open the app using the
webAppCompiler
function at the MATLAB Command Window.After you open the app, the Create Deployment Task dialog box prompts you to add a deployment task to a new or an existing MATLAB project. Deployment tasks allow you to compile files in a project for a specific deployment target. For more information on creating and using MATLAB projects, see Create Projects (MATLAB).
A new deployment task named
WebApp1
opens in the Editor.In the MAIN FILE section of the toolstrip, click the
button to add your App Designer
.mlapp
file to the project. The Web App Compiler automatically resizes to include an App details section that contains information about the app such as app name, author, summary, description, and version. You can edit information about the app in App Designer by clicking Edit App Details. Click Refresh to update Web App Compiler with any changes you have made.Add supporting files, if any, in the Files required for your app to run section. Supporting files include any MAT-files, images used by your web app, or user-written MATLAB functions not found by MATLAB Compiler.
Click Package to package the app, and create a web app archive (
.ctf
file).In the Save Project dialog box that opens, specify a project name and a location where you want to save the web app project. Web App Compiler saves your project and opens a Package dialog box.
Once packaging is complete, in the Package dialog box, click Open output folder. This step opens the project folder which contains the following files:
webAppArchiveName
.ctfmccExcludedFiles.log
PackagingLog.html
requiredMCRProducts.txt
You can view the log file,
PackagingLog.html
, to see the exactmcc
syntax used to package and create the web app archive.To use the web app, deploy the web app archive file,
. For more information, see Deploy Web App.webAppArchiveName
.ctf
Create Web App Using compiler.build.webAppArchive
As an alternative to the Web App Compiler app, you can create a web app using a programmatic approach. If you have already created a web app using the Web App Compiler, see Deploy Web App (MATLAB Compiler).
Use the compiler.build.webAppArchive
(MATLAB Compiler) function in MATLAB
Compiler to package your web app by specifying the application file, archive name,
and output directory. For
example:
compiler.build.webAppArchive("Mortgage.mlapp",... 'ArchiveName','MyMortgageWebApp',... 'OutputDir','D:\Documents\MATLAB\work\WebApps')
Deploy Web App
Navigate to the project folder generated by MATLAB Compiler during the packaging process.
Copy the web app archive (.ctf
file) to the app folder configured
by the server. The default location is:
Operating System | Apps Folder Location |
---|---|
Windows® |
|
Linux® |
|
macOS |
|
You can also get the location of the apps folder by executing
webapps-status
at the system command shell.
Open a web browser and navigate to the web apps home page using
the URL obtained from executing the webapps-status
command. You see a tile displaying the web app. Your web
app is now deployed.
Compatibility Considerations
In most cases, you can generate a web app archive (.ctf
file) on
one platform and deploy to a server running on any other supported platform. Unless you
add operating system-specific dependencies or content, such as MEX files or Simulink® simulations to your applications, the generated archives are
platform-independent.
See Also
compiler.build.webAppArchive
(MATLAB Compiler) | compiler.build.WebAppArchiveOptions
(MATLAB Compiler)