PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label gitignore. Show all posts
Showing posts with label gitignore. Show all posts

Friday, August 19, 2022

[FIXED] How do you reference a process.env variable in HTML <script src="" ? React

 August 19, 2022     environment-variables, gitignore, google-maps, reactjs, webpack     No comments   

Issue

I have a react app and am using dotenv-webpack to manage my API keys.

I have: - created a .env with the API keys and gitignored it. - required and added dotenv as a plugin in webpack.config.js.

After that, I've been able to reference one of the keys in a .js file by using process.env.api_key. But I am having problems trying to reference it in index.html in the script tag.

index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/style/style.css">
    <link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/48938155eb24b4ccdde09426066869504c6dab3c/dist/css/bootstrap.min.css">
    <script src="https://maps.googleapis.com/maps/api/js?key=process.env.GOOGLEMAP_API_KEY"></script>
  </head>
  <body>
    <div class="container"></div>
  </body>
  <script src="/bundle.js"></script>
</html>

How do I reference the process.env.API_key here?

<script src="https://maps.googleapis.com/maps/api/js?key=[API_KEY]"></script>

I have tried using backquotes that work in .js file, like so ${API_KEY}, but that does not work in the .html file.


Solution

I put the following code in componentWillMount where the map renders and it worked (at least in development: const API_KEY = process.env.GOOGLEMAP_API_KEY; const script = document.createElement('script'); script.src = https://maps.googleapis.com/maps/api/js?key=${API_KEY}; document.head.append(script);

I was able to get this to work using the code posted by bigmugcup in the comments above. I did not modify the webpack.config.js file.



Answered By - Tbot
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, July 1, 2022

[FIXED] What files and folders to include in .gitignore in Shopify Themes Development

 July 01, 2022     github, gitignore, shopify, shopify-template     No comments   

Issue

I'm new to Shopify Themes Development. I downloaded the free Shopify theme template using Themekit. I want to push the theme to Github but in VS Code it's showing that there are 156 files to be pushed on Github.

Folder names are: assets, config, layout, locals, sections, snippets, templates

File name: config.yml

That's obvious, this is not a way.

Can someone please tell me what files and folders i need to write in .gitignore So that those won't be pushed on Github.

Thanks in Advance!


Solution

Shopify has an example .gitignore in their starter theme. I'm not sure why they don't include settings_data.json but I would definitely include it. Here's what I'd use:

# Shopify #
###################
config.yml
config/settings_data.json

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db


Answered By - user172877
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, May 19, 2022

[FIXED] How do I push files specified in .gitignore?

 May 19, 2022     composer-php, git, git-push, gitignore, phpfog     No comments   

Issue

If I have a "vendors" directory in my .gitignore, is there a way I can set up a remote that will receive that directory anyway when I do a push?


Solution

I think the functionality you're looking for can be achieved by having a branch used to deploy to your Cloud Provider.

Setup a dev branch which includes your .gitignore file, check your incremental work into that branch.

Merge your dev branch into your deploy branch which doesn't contain a .gitignore file but contains the vendors directory.

once you've completed your merge, push to the deployment remote from your deploy branch.



Answered By - cory-fowler
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, May 11, 2022

[FIXED] Why is Symfony/Git ignoring some of the folders?

 May 11, 2022     git, gitignore, symfony     No comments   

Issue

I just noticed that when I push my Symfony project to Gitlab, some of the folders (for example "vendor") are not pushed (because they are ignored by .gitignore).

Why is this? And isn't it problematic if I then want to clone the project from Gitlab onto my other computer, where I then would be missing the vendor folder?


Solution

Typically you don't want to include the vendor folder in git, as that can be rebuilt when you deploy by saving your composer.lock file.

Your deploy should use composer install to build the vendor directory, and it will use the same files as those installed by composer in your source commit(s).

In summary:

  • When changing packages via modifications to the composer.json, run composer update.
  • Save/commit changes to composer.lock
  • clones of the repo should run composer install
  • composer does more than just fetch and install dependencies -- it also runs utility scripts, and differentiates between production and development environments. It will also build the autoload script for inclusion in your project.
  • Running composer install can be done whenever you would like, so you can run it everytime you git pull if you want. It should be idempotent with git repos.
  • For a production environment there are options to consider like using the --no-dev flag. composer install --no-dev This will omit any development libraries, however, it is important to have a staging environment to insure you've actually tested that build somewhere. You might want to research and consider these additional options for a production deployment: composer install --no-dev --no-scripts --optimize-autoloader.


Answered By - gview
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, February 15, 2022

[FIXED] Using github and MAMP

 February 15, 2022     git, gitignore, mamp, mysql, php     No comments   

Issue

I have MAMP setup on my mac, and I have a web app installed in the htdocs folder that use my mysql databases. So far everything is working great. The problem is the project is using git, so I installed the github mac app. Theres a .gitignore file that includes a bunch of files, but I'll just list one to explain my problem. This file is in in .gitignore:

/application/config/development/database.php

But, when I make changes to it, it displays in my change list. Using the github mac app, I right click and choose ignore, and it inserts this path into my .gitignore file:

application/config/development/database.php

Notice the missing '/'. But then, .gitignore shows up in my uncommitted files, and the database.php file is not ignored! Also, .gitgnore is in the .gitignore file as well. Is this a relative path problem? A git installation problem? Halp!


Solution

Usually .gitignore is commited (and pushed) like any other project relevant file. When it shows up under changed (but not staged) files, it is ok. You should commit and push it.

The fact that.gitignore contains itself makes absolutely not sense, I would recommend to remove this line.

The paths in .gitignore are relative to its location. When .gitignore is in /home/foo/bar then /herp/derp.php in .gitignore means

/home/foo/bar/herp/derp.php

whereas herp/derp.php in .gitignore will match

/home/foo/bar/herp/derp.php

as well as

/home/foo/bar/baz/herp/derp.php

The fact that the database.php shows up under changed/uncommited files means quite sure, that this file previously has been commited. You will havt to remove it from the working tree:

$ git rm /application/config/development/database.php

and commit the changes along with the changes in .gitignore.

Hope this helps!



Answered By - l-x
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, January 19, 2022

[FIXED] laravel symlink is changed when code is pushed to live site

 January 19, 2022     gitignore, laravel-5, storage, symlink     No comments   

Issue

I am using laravel 5.5's storage symlink to store images. When I push code to the git and pull from live site then symlink path on live site becomes same as is on my local code . My local has this symlink

 storage -> /home/path/to/project/app/public/ 

But live site expects this symlink path

 storage -> /var/www/html/website.com/public_html/project_code/storage/app/public/

Every time I have to delete symlink and create it again on live site. I have do these steps on live site

cd public
rm storage
cd ..
php artisan storage:link

after doing these steps my symlink becomes according to live site and then it starts working. Live site should have this symlink

storage -> /var/www/html/website.com/public_html/project_code/storage/app/public/

project_code/.gitignore :

public/storage

project_code/storage/app/.gitignore

 *
 !public/
 !.gitignore

How I can get rid of this issue.

Thanks in advance!


Solution

As your symlink points to another location within the same project, you can safely use relative paths while linking, instead of having absolute one (which is what artisan is setting up). That would require manual linking though:

cd app/public
ln -s ../storage/app/public storage

Remove current storage symlink first if you have it already.



Answered By - Marcin Orlowski
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing