Hello, Sorry if this has been asked before, I was unable to find an answer to this question. Not sure If I am asking the question correctly to find the answer.
I have a project that someone has shared with me and I would like to view/use it on xampp. I have little to no experience with Yii2 or Composer. The Package has a yii and yii.bat files along with composer.json and composer lock file. which has lead me to believe that is was create using this frame work. I have tried to do a composer install in the web directory, but when I view the application from localhost/filedirectory i get a page where it states âlocal file is not setâ.
I am not sure if I have all of the file in the package to run the program or If there is sequence of command I must run to build the project on my computer.
Is there a guide or instruction for how ti install / rebuild or set up an existing project on different computer from the one it was originally built on? I was able to get a basic and advance template to work so I believe that I have the required software installed, Just not having much luck with this pre existing project.
I have been searching and found plenty of examples on how to build a new project, but really nothing on how to use an existing project on another computer.
Any help or directions would be greatly appreciated.
Hi, this is a unique situation based on your own circumstances - i.e. whatever you have been given in terms of the project files and also the local environment that you have - so there will not be much similarity to any questions asked before.
You would not be running the command âcomposer installâ in the web directory, it would be done in the root directory which should be 1 level back up.
I guess there are a number of things to sort out here:
1. Check folder/directory structure
first place to start is compare your project folder structure to a fresh copy of Yii2 and see from the top level if any obvious folders are missing. If the âvendorâ folder is empty then run the command âcomposer installâ and it should update that folder for you. 2. Do you know which version of PHP are you using locally 3. Do you know which version of Yii2 the project is based on - is it old or fairly up to date?
To test your application without the need for xampp at the moment see here - jump to the section as per below:
Turn xampp on so PHP and your database is running but start the application as per below using the command line.
Specifically look at the section titled âVerifying the Installationâ here:
Let us know how you get on and what the output is.
Hello, Thanks for the help, To answer some questions:
The Folder structure is missing Web and Vendor. Doing a update and install in the root folder fix the vendor issue. I had to down grade my version of PHP from 8.1.2 to version 7.3 something to get the required dependencies to update. After installing I was still missing the Web folder, I not sure that is the problem though because in the root folder there is a index.php file the attempts to load when I run âphp yii serveâ The page display an error though. âLocal file not setâ.
In the terminal it dies and return back to the prompt also., after doing a little digging in the program i found the file that is causing this. It is the constant.php file:
<?php
$localFile = __DIR__ . "/../local-config/local.php";
if(!file_exists($localFile)) die("Local file is not set.");
require $localFile;
this file is not include in the directory that it is looking at.
I am not sure of the version of Yii2.
I am going to take a step back and work with a basic template and learn a little more before continuing with this project. I need to get a better understand on how the frame work works, then I think I can figure this out.
Thanks for being patient with me and taking the time to help me answer the question.
The vendor folder directory will typically be empty as it does not usually get shared, this is what composer handles for you - it draws down all of the dependent packages that the application requires - so this is normal and now all sounds good.
Also you have brought your version of PHP into alignment which is another good step forward. We can always upgrade to a newer version of PHP later.
So this now leads us to your overall underlying problem, there is a custom configuration file missing - or it is currently sitting inside another folder somewhere. This âconstant.phpâ file you have found is not part of the Yii framework which now explains the original error message your support topic was referencing.
You can either suppress the error message in that file - or remove/rename the file for the time being to see if your application fires up. However the trick will be that we need to try and work out what was actually in that file - it was probably just configurations specific to the developers local environment.
If you look into one of your fresh copy of Yii2, look inside the âconfigâ folder directory and open the file âweb.phpâ. If you get that into this broken application then it should work. It might already be there so try to remove the constant.php file first and let me know how you get on.
Also that missing âwebâ folder could have been renamed to something else. It should have something similar to the following directories and files inside it: