Yii2 fresh install: vendor/bower/jquery/dist path is wrong - yii2

I just installed yii2 (advanced) using composer. I've setup nginx, etc.
But it doesn't work:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: /srv/www/site/vendor/bower/jquery/dist
In the folder 'vendor/bower' there is the only subfolder 'bower-assets' with 'jquery', etc in it. But no jquery in vendor/bower.
How to solve this issue?

Please, refer the installation guide. It seems that you are missing asset plugin:
composer global require "fxp/composer-asset-plugin:~1.2.0"

Make sure you have executed this command:
composer global require "fxp/composer-asset-plugin:~1.2.0"
Also, check your composer.json for these followings:
Deprecated, but default option from Yii2:
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
},
New option
"config": {
"fxp-asset": {
"installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
},
}
},
Then run either composer update if you already have a composer.lock file, or composer install if you don't have composer.lock file yet.

Check your composer.json file in the root of your project. You should have a section that look slike this;
"asset-installer-paths": {
"bower-asset-library": "vendor/bower-assets"
}
This tells composer where to locate the bower files library. You may need to run composer update afterwards to get hte locations updated.

I was facing same issue,
this is how I fixed it-
go to vender .
$ cd projectFile/vendor/
Rename bower-asset with bower
$ mv bower-asset/ bower
Restart mamp/xamp
That fixed the issue and http://localhost:8888/ is working well.

It seems your jquery/distis under bower/bower-asset instead under bower.
In order to solve your problem, please move all bower-assetcontent including jquery subfolder and others like: bootstrap, yii2-pjax, puny code, etc. in bower folder (one level up). All these subfolders will be at the same level with bower-asset under bower folder. Now you can delete bower-asset folder if you want.
Before you had:
vendor/bower/bower-asset/jquery/dist/...
Now you have:
vendor/bower/jquery/dist...
There shouldn't be any bower-asset subfolder.
This will solve your problem and yii2 app will work as it should.

Related

How to change file directory after build?

How to move my index.html file to 'dist' folder after build? Before npm install and npm run build folder 'dist' s not located in my project it appears after first build and after that I'd like to move automatically my index.html file to this location.
I was searching information on the Internet, found only two thing that attatched to my eyes.
One was "html webpack plugin" but it only creates a new empty index.html folder after build
Second, I found some plug in on github that theoretically can move file to choosen directory but I not working
You can just issue a cp command at runtime. Inside your package.json file, in the scripts section, add an additional command. IE
"scripts": {
...
"build": "react-scripts build && cp build/index.html ../dist/index.html",
...
},

Downloaded ZIP from from CodeSandbox (Vue.JS page) index.html produces blank page

My first ever Vue.JS / Vue2Leaflet app works fine on codesandbox.io, but when I download the ZIP and open the index.html file, it is blank?
Do I need to do something to the code base (compile? install additional dependencies?) before it works? I am looking for something I can upload on a server...
Alternatively, how difficult would it be to convert this to a single .html page? (Single File Component?)
I'm not sure how this project is configured but I advise you to convert it to a default #vue/cli setup.
npm install && npm install -D #vue/cli-service #vue/cli-plugin-babel vue-template-compiler postcss-import postcss-url && npm install core-js
Edit .babelrc so it just contains:
{
"presets": ["#vue/cli-plugin-babel/preset"]
}
Create public folder and move index.html in it.
Create src folder then move App.vue and index.js into it
Rename index.js to main.js
Edit main.js to replace template: '<App/>', components: { App } by render: h => h(App)
Delete build and config folders
Edit package.json to add
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
}
And run either npm run serve or npm run build
Also, in App.vue :
Replace :key="office.id" by :key="'office' + office.id"
Replace :key="factory.id" by :key="'factory' + factory.id"
Replace :key="warehouse.id" by :key="'warehouse' + warehouse.id"
(because you can't have the same components (l-marker) within the same parent with the same keys)

No valid bower.json was found in any branch or tag of https://github.com/yiisoft/jquery-pjax.git

Hello I have some issue with composer installation after installing your package in composer globally. See the error below
[Composer\Repository\InvalidRepositoryException]
No valid bower.json was found in any branch or tag of https://github.com/yiisoft/jquery-pjax.git, could not load a package from it
You need to try these solution and usually its will be fixed:
1) if you have antivirus turn it off since its maybe block some of needed port.
2) run this command composer clear-cache in your project.
3) if first and second solution not work, then go to /root/.composer directory, and create file config.json and put these command inside it.
{
"config": {
"preferred-install": "dist",
"github-protocols": ["https","http"],
"github-oauth": {
"github.com": "YourGithubOauth"
}
}
}
then clear cache again. and I wish its work.
Good luck.

Yii 2 - Overriding files of mdm extension in vendor to extension folder using aliases in config

I have installed mdm extension for admin in basic version of Yii2, that is located in vendor directory and I want to override some files into extension directory for UI changes, I referred this link and added some code in web and console file as:
'aliases' => [
'#mdm/admin' => '#app/extensions/mdm/yii2-admin',
],
But no changes are reflected after doing this.
Most likely version installed by Composer conflicts with version which you unpacked manually. Instruction in documentation are for installing extension without using Composer, so they're definitely not considering the fact, that you have the same extension installed in two different places.
If you want to edit this extension you should uninstall composer version and copy whole extension into extensions/mdm/yii2-admin.
But probably better option would be to fork it, and add repository to your composer.json which will point to your fork:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/yourname/yii2-admin.git"
}
],
And change dependency constraints to use master branch:
"require": {
"mdmsoft/yii2-admin": "dev-master as 2.8.0",
// ...
},
Then all necessary changes you're preforming in your fork (at https://github.com/yourname/yii2-admin.git) and fetching changes to main project using composer update mdmsoft/yii2-admin. It will simplify syncing changes from upstream - you just need to merge changes for upstream if you want to update your fork with lates changes from original extension repository.

Unable to save file: Permission denied Ubuntu

With the help of a YouTube tutorial, I am working on my first MEAN stack project. So far, I have created index.html, server.js and package.json files. When I installed Mongoose and Body-Parser using terminal, my package.json file stored in Documents showed updated dependencies for package.json like
{
"name": "njnjn",
"version": "0.0.1",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"mongoose": "^4.7.5"
}
}
but I did not see updated dependencies on Atom which had something like
{
"name": "njnjn",
"version": "0.0.1",
"dependencies": {
"express": "^4.14.0"
}
}
So, I could not see the updated dependencies for Mongoose and body-parser on the package.json. I'm working on in Atom but I could see the updated dependencies for mongoose and body-parser on package.json in Documents.
I want the dependencies to be updated on both files: the one in Documents and the one I'm editing in Atom (I thought those files were supposed to be the same)
Also, when I tried saving my package.json on Atom(one without updated dependencies for Mongoose and body-parser), an error message popped up saying "Unable to save file: Permission denied." I don't think this error is associated with Atom only because I could not save my package.json file on Sublime as well.
How do I solve this problem so that dependencies for mongoose and body-parser will be updated on the package.json file in my text editor. And how can I save my package.json file on my text editor?
I tried searching everywhere for solution and saw a similar problem on Stack overflow for which the best solution told "to temporarily become root and edit the file:
sudo atom /path/to/file"
Because I'm new to Ubuntu, programming and command line, I did not understand the solution. Could you guys please help me?
you can set the permissions recursively.
sudo chmod -R 777 your file path
e.g.
sudo chmod -R 777 /path/to/file
for more information click on this link
"Permission denied" means that your current user have not the authentication to change the file. Only the owner of the files and root have the authentication to change them in default.
sudo+command means you will use root's authentication. This requires that your current user is in 'root' user group(That also means that your current user is in sudoers).
You can get more help here:https://en.wikipedia.org/wiki/Sudo
By the way, you are the owner of /home/yourUserName in default. Maybe your file should be created there?
This error occurs because of the following problem
1:- Those folders do you want to save your file is private that's why they say access denied
For salve, this problem follow the command
1 :- $ sudo su
2:- Go on that folder you want to save for example
$ cd Desktop
3:- $ chown -v user-name /foldername