I'm working with Yii2 and trying to init some migration files. This was working a few months ago, now I'm getting the following error
'yii' is not recognized as an internal or external command
command I'm trying to run is 'yii migrate/create init_my_table
I've been looking around but not exactly sure what the problem is.
Seems like this should be a pretty generic and easy to fix error...
Before i delve into proposing a solution, check if you installed Yii's Basic Template or the Advanced Template.
$ php yii serve
will work for the "basic" template.
Make sure at the Terminal, you have changed to the "basic" directory, then enter the command:
$ php yii serve
OUTPUT
Server started on http://localhost:8080
Document root is "PATH/public_html/yiiproject/basic/web"
Quit the server with CTRL-C or COMMAND-C.
IF you are using the Advanced Template, read this thread and see if the Thread here helps. Read it till the very end:
http://www.yiiframework.com/forum/index.php/topic/68728-php-yii-serve/
Had this same issue but was using the Advanced template.
php yii serve Could not open input file: yii
i tried this command as recommended. It worked:
$ php -S localhost:8000
Hope this helps.
UPDATE FOR ADVANCED TEMPLATE
After installing Composer and Yii, open your Advanced template folder in CLI and run this command:
$ php ./init
This initialization process will setup the project and create necessary files.
Set your document root properly in apache to your /advanced/web/
More Reading to run your project:
http://www.yiiframework.com/wiki/799/yii2-app-advanced-on-single-domain-apache-nginx/
http://www.yiiframework.com/doc-2.0/guide-start-installation.html
Make you that your Environment Variables are set up correctly.
Check out these links:
Similar question
Environment Variables
Relevant parts from links:
To access the environment variables right click the My Computer icon then choose properties. Select the Advanced tab and then click Environment Variables.
window you should see
path :=>...;D:\YOURPATH\xampp\php;D:\YOURPATH\xampp\yii\yiiframework;
Try installing composer globally. I had similar issue but it was resolved after I installed composer via installation file and using my environment variables, I made available globally.
Related
At work we took back our existing store running on Magento 2 from an external development agency. I need to get the project running in local development (with docker).
I familiarized myself with a vanilla project from the official docs and managed to get it running by downloading the vanilla template with composer, granting the proper permissions on files and folder and running the magento setup:install command.
My question is how do one goes when kick starting from an existing (production running) project?
Do I need to run setup:install again? If I do, why?
What do I need to import from production to ensure any content or configuration created via the admin is also running on my local setup? Should I import the complete Database from production?
I know our setup is using more than just php and mysql, but env.php seems to be listing only db configuration and admin url. Where can I get the complete service configuration informations about what our setup uses?
Anything else I am missing to get started with an existing project for local development?
As someone who is running Magento 2 on a local environment myself, hopefully I can shed some light on this.
If you have a direct copy of the live site, you do not need to run setup:install again.
Ensure you have a copy of the entire Magento 2 site (you can technically ignore the vendor folder, as you can run composer install and it will redownload those files, but that's up to you). Also get a copy of the entire database. Magento 2 is notorious for copying the same data to multiple tables so something could break if you don't have everything.
What do you mean by "service configurations" If you are referring to Magento 2 extensions, that data is saved in the database, not the env.php file. env.php is only for server side configurations, such as the DB information, Caching, and things of that nature. On mine, I use Redis for site Cache, so that would be included in that file as well, as an example.
When you first unpack the site to your local environment, run composer update in the directory. This will ensure you have all the proper files installed. If you are going to run a local dev environment, set the mode to development with the following command: bin/magento deploy:mode:set developer. This will allow you to make changes and to view those changes by just refreshing the page, rather than flushing cache all the time.
All queries are replied correctly by Eric. I am also not sure about "service configurations" you have mentioned here. If this is about third-party extensions/services you can check config.php file for this.
This might be a very newbie question but, how exactly do you use phpDocumentor to generate your docs through Laravel? In my Laravel project there's no phpdoc in the vendor/bin directory, and trying to install phpDocumentor via composer fails (as suggested on the GitHub page).
I couldn't find any recent resources about it, the only thing I had luck with is running the phpDocumentor.phar file from the terminal, but the newest version fails immediately.
To get this working, downgrade to PHP 7.1. Then download the latest phpDocumentor.phar file from [http://www.phpdoc.org/phpDocumentor.phar]. Place the phpDocumentor.phar into your Laravel 6.x project's /vendor/bin/ directory.
Then use Homebrew to install other needed packages...
brew install intltool
brew install graphviz
Lastly, cd into /vendor/bin and run...
php phpDocumentor.phar -d ../../app/Http/Controllers
Your documentation output should be at /vendor/bin/output.
Adding a more complete solution that worked for me on creating documentation of my Laravel project with the system environment comprising of MacOS Catalina,Laravel 6 and PHP 7.2.
Visit https://docs.phpdoc.org/3.0/guide/getting-started/installing.html. To install the dependencies, recommended to update homebrew as brew update and brew upgrade. After updating the homebrew, execute the following:
brew install graphviz
brew install plantuml
Once the dependencies are installed, download the phpDocumentor.phar from the above link, and make the file executable as follows:
chmod +x phpDocumentor.phar
Then, copy and paste this file to your laravel app under /vendor/bin
I also placed this file under local bin mv phpDocumentor.phar /usr/local/bin/phpDocumentor for easier access (as shown in step 6 below).
For testing purpose, create a simple test.php file under /vendor/bin/docs/test.php directory with the following content as mentioned in https://docs.phpdoc.org/3.0/guide/getting-started/your-first-set-of-documentation.html
<?php
/**
* This is a DocBlock.
*/
function associatedFunction()
{
}
Then execute the phpdoc script from the same /vendor/bin location as:
phpDocumentor.phar -d docs/test.php -t docs/test
This will generate several files.
Open the index.html file generated in your web browser (eg. Chrome) to view the documentation:
open -a "Google Chrome" ./docs/test/index.html
Notably, because we placed the phpDocumentor.phar in /usr/local/bin/phpDocumentor/phpDocumentor.phar, we can easily access phpdoc and easily create the documentation of our whole App as follows ( the documentation will be stored inside the folder DOCS)
phpDocumentor.phar -d app/ -t DOCS/
I have found the problem with most PHP documentation solutions is they require large amounts of code just to get something you can actually use. And that takes a lot of time and trial and error to set up.
I also have issues with the generated documentation. Often it is not even sorted! Also it is hard to navigate and understand the whole class. As a consumer of a class, you are not interested in private or even protected things (unless you are trying to extend it). But often the docs only show you the methods and properties of the current class, and not what it inherits (which is the WHOLE point of OO!).
Anyway, I got sick of the current state of PHP documentation and decided to do it right. I wrote PHPFUI/InstaDoc to address all the issues I had with existing solutions. InstaDoc is the fastest document generator out there because it simply scans the class directory structure and saves it off. This generally only takes a few seconds (for large code bases) each time you generate (on release, or if you add a new class in your dev env). Then it renders the docs for a specific class at runtime, because, hey, who ever looks at the documentation anyway? Just us nerds, and there are not many of us, and we can wait a fraction of a second for the server to generate the docs on the fly. Also you don't need server disk space to store all your docs. They are generated on the fly. And of course if you have a high volume site, InstaDoc can generate static HTML files, but who has a high volume PHP doc site (like nobody).
Anyway, check out a live example at PHPFUI/InstaDoc and see if it fits your needs. It is not a Laravel module or plug in, but you should be able to run it under Laravel easily. Just return the output of the controller in your controller, and it should just work.
I'm still really new to Git version control and Laravel. But I have gotten so far, and I'm not sure now where I am going wrong.
I set up VirtualBox and Vagrant on my local windows machine and installed homestead successfully. I have managed to get my Laravel website (it's only one page at the moment as I learn things) working correctly, it displays the header and the footer and the images load and everything. So that's all good.
So now, I have my Laravel website set up within my virtual vagrant server. On this server, the directory for my website is:
/home/vagrant/Code/sites/public_html
No when I cd to that directory, I ran the following:
git init
get remote add origin https://user#repo/user/publichtml.git
git add *
git commit -m "Initial Commit"
git push -u origin master
(I've substituted user#repo instead of the real URL)
All went through successfully. Great. So now on my live server I ran the following:
cd /home/sites/public_html
git init
git clone https://user#repo/user/publichtml.git
Which again, worked fine. It downloaded all the files into the public_html directory which is great. So then I go to visit the website and this is what I get:
The only explanation for this happening is maybe I need to install something on the server before I clone these files to it. I guess the files in the Laravel folder won't run by themselves? Do I need to install composer and laravel on the server or something? If so, how do I do that, and why don't they run on their own?
I cannot see a .htaccess or index.php in the root directory so I am not sure how it runs anyway.
You should install Laravel using composer instead.
composer create-project laravel/laravel mysite
You should also point the document root on your web server to laravels "/public" folder, making the framework code reside outside of the document root. That's good for security (no one can access any framework code, like your configs etc directly).
You will then find the .htaccess-file in the /public folder.
Please read the Laravel documentation about the different but recommended ways to install Laravel.
Btw, doesn't homestead use Nginx instead of Apache? In that case, .htaccess isn't even used. Please refer to the Laravel documentation again regarding homestead.
You need to redirect traffic to public/index.php instructions for this are webserver dependent.
I am needing some help setting up a Yii2 Advanced Application on Heroku. I have already installed Yii locally using Composer, following their guide exactly: http://www.yiiframework.com/doc-2.0/guide-tutorial-advanced-app.html
My website works as it should locally, with frontend and backend:
http://localhost/yii2app/frontend/web/
http://localhost/yii2app/backend/web/
When I push it and run it on Heroku, I get errors complaining that some files are not found. What is weird, is with a bash terminal to my Heroku app, I can verify that the file is in fact there! Is Heroku not liking the '../../' to change directory?
PHP Fatal error: require(): Failed opening required '/app/frontend/web/../../common/config/main-local.php'
include_path='.:/app/.heroku/php/lib/php') in /app/frontend/web/index.php on line 12
In 'frontend/web/index.php' is Yii's stock code (line 12 is main-local.php):
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php')
);
If it had to do with the '../../' to change directory, then I would think the first require would have an error (for the main.php entry).
What am I missing to get Yii2 advanced running on Heroku?
UPDATE - I created a new Yii2 basic app. Should work and be simple, so I thought. Apparently even the basic app does not run on Heroku. There MUST be something left out from the docs, somewhere... Used composer to install Yii2 basic, put it under git, pushed it to a new heroku stack. Went to check out my app on heroku, adding /web/index.php to the end of the url.
ReflectionException
Class yii\debug\Module does not exist
I then put index.php in the root directory containing phpinfo(). I can confirm I get a phpinfo report. So php is running, it reports PHP 5.6.5.
Seems like Yii2 and Heroku do not play well without some magical (and un-documented) tricks. I have searched, and searched, and searched, and I can't find anything about this. I can't possibly be the only one trying to get a Yii app onto Heroku.
So I tried CloudControl. I deployed my stock Yii2 basic app to cloudcontrol, again I get a phpinfo report on the root index.php. Navigate to /web/index.php and get errors:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: /srv/www/code/vendor/bower/jquery/dist
What gives! I can run this locally just fine. When I push it to a cloud based host (Heroku or CloudControl) it fails! I figured the yiibasic app would be better to at least get it running for PoC, but Yii out of the box, will not run on either of those services. There is something not mentioned that I am missing.
Finally after hours and hours of messing around, I figured it out. Well, I still have one question left that I need to test (and try again). However, I managed to get both the yii basic and yii advanced apps running on Heroku. Still got errors on CloundControl though, but that's for another day.
I was missing 2 entries in my composer.json file. I dunno why these are not included in the Yii documentation if they are required in production. Here is my require block (I did not have to edit the require-dev section, just require):
"fxp/composer-asset-plugin": "*",
"ext-gd": "*"
The composer asset plugin was absolutely required. The GD extension is needed for the contact us page (I assume the captcha). I also commented out the first 2 lines in web/index.php for the YII_DEBUG defines. Once I did that, updated composer, updated git, and pushed, magic happened :)
I don't think they inform you that you need to edit web/index.php to remove them in the Yii2 docs. Seems they are only interested in getting you going for development. Yes the index file has comments, but we need to know to look there! If you don't remove them, Yii will load your debug tools, which don't exist. I assume when Heroku receives the push, it runs composer from the "require" block.
As for the Advanced template.. Frontend and Backend index.php files already have the debugging constants correct for dev and production. You just have to run php init --env=Production --overwrite=All on the server (I couldn't get heroku to do this, but another day). The Yii docs have you run init, then select development. This takes everything from the "environments/dev" folder and overwrite them in their locations in your app. This will fail when in development. So you have to switch it to production, which moves your production files into use. I understand why you would have these, so I get it.. Like I said, I tried heroku run bash, then running php init --env=Production --overwrite=All from the apps directory but it didn't seem to make the switch. So my app was missing the frontend/web/index.php file, and many more.
I was wondering how 'frontend/web/index.php' wasn't even in the directory, but further inspection I saw that many directories have gitignore files. So when you 'git push heroku master', 'frontend/web/index.php' along with the rest, never get pushed because they are ignored. So because I couldn't get Heroku to run Yii's init into production, my files just were not there.
Simple fix to get me running on Heroku with Yii Advanced (including adding the 2 mentioned packages to composer.json): I deleted all the gitignore files, ran init choosing production, updated git, and pushed to heroku. It runs :)
Now I need to figure out how to get init to do this for me so I don't have to delete the gitignore files.
As for this question, it is solved. Heroku can run Yii2 basic and advanced. The biggest issue I see is the Yii docs lacking the necessary composer packages to run in production. So I wonder if it's just Heroku needing those packages...
I'm trying to run a Symfony project that I cloned from a GitHub. I've never used Symfony before but I'd like to run the project.
I read you needed to run frontend_dev.php so I ran that in to my browser:
C:\Users\Computer\Desktop\Project\WebInterface\web\frontend_dev.php
But just got a blank page with some PHP on it. I believe I may have to set up a web server but I'm not sure and figured I'd ask here first.
If I wanted to run the project from my computer, would I just download an Apache server and drop it in the root directory? What variables and files would I need to change to get it working properly? Do I need to forward any ports?
Symfony 1.x branch is not supported anymore. Use Symfony 2.
Anyway, concerning your question: here is the doc for 1.4: Day 1: Starting up the Project