FriendsOfSymfony (FOS) package missing on deployed GAE app - google-app-engine

I'm deploying my php 7.4 app with framework symfony 5 on Google App Engine.
The problem is, friendsofsymfony package is nowhere to be seen in the source folder 'vendor' of the deployed app on the App Engine.
I followed the installation of the package on Symfony FOSCKEditorBundle
(Download the bundle, register the bundle, install the assets, configure twig).
I do have the bundle inside of public, but composer doesn't seem to install the ckeditor-bundle package in the vendor folder. Locally everything works fine, upon composer install/update he downloads the package and app runs fine.
Composer.json
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"friendsofsymfony/ckeditor-bundle": "^2.2",
"google/cloud-dialogflow": "^0.13.0",
"knplabs/knp-paginator-bundle": "^5.2",
"league/csv": "^9.0",
"nelmio/cors-bundle": "^2.0",
"sendgrid/sendgrid": "^7.7",
"sensio/framework-extra-bundle": "^5.5",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.0.*",
"symfony/console": "5.0.*",
"symfony/dotenv": "5.0.*",
"symfony/expression-language": "5.0.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.0.*",
"symfony/framework-bundle": "5.0.*",
"symfony/http-client": "5.0.*",
"symfony/intl": "5.0.*",
"symfony/mailer": "5.0.*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "5.0.*",
"symfony/orm-pack": "*",
"symfony/process": "5.0.*",
"symfony/security-bundle": "5.0.*",
"symfony/serializer": "5.0.*",
"symfony/serializer-pack": "*",
"symfony/string": "5.0.*",
"symfony/translation": "5.0.*",
"symfony/twig-pack": "^1.0",
"symfony/validator": "5.0.*",
"symfony/web-link": "5.0.*",
"symfony/yaml": "5.0.*"
},
"require-dev": {
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.0.*"
}
}
}
app.yaml
# Use the PHP 7.3 runtime (BETA) by replacing "php72" below with "php73"
runtime: php74
env_variables:
APP_ENV: prod
APP_SECRET: ###
DATABASE_URL: ###
# APP_DEBUG: true
## For connecting to Cloud SQL with Doctrine
## This is used in part two of the README:
# DATABASE_URL: mysql://root:DB_PASSWORD#localhost?unix_socket=/cloudsql/INSTANCE_CONNECTION_NAME;dbname=symfonydb
handlers:
# Declare the build and bundles directory as static assets to be served by the
# App Engine CDN.
- url: /build
static_dir: public
- url: /bundles
static_dir: public
# Declare any media files in the public directory as static assets as well.
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /images
static_dir: images
- url: /node_modules
static_dir: node_modules
- url: /Theme/META-INF/resources
static_dir: Theme/META-INF/resources
- url: /bundles/fosckeditor
static_dir: bundles/fosckeditor
basic_scaling:
max_instances: 5
fos_ckeditor.yaml
# Read the documentation: https://symfony.com/doc/current/bundles/FOSCKEditorBundle/index.html
twig:
form_themes:
- '#FOSCKEditor/Form/ckeditor_widget.html.twig'
fos_ck_editor:
configs:
main_config:
toolbar:
- { name: "styles", items: ['Bold', 'Italic', 'Underline', 'Strike', 'Blockquote', '-', 'Link', '-', 'RemoveFormat', '-', 'NumberedList', 'BulletedList', '-', 'Image', 'Table', '-', 'TextColor', 'BGColor', 'Source'] }

Related

Refused to execute script from '.../bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled

I have an application with React/webpack frontend and Django/python backend. It has deployed successfully to heroku in the past. It has been sometime since I did anything in the application and after some recent updates I wanted to update the deployed version. Heroku reports that the application deployed successfully but when I try to access it, I get the error:
Refused to execute script from 'https://pairshead-2020.herokuapp.com/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Here is my webpack.config.js:
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: './src/app.js',
context: path.resolve(__dirname, 'frontend'),
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'frontend/dist'),
publicPath: '/'
},
devtool: 'source-maps',
module: {
rules: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
{ test: /\.s(a|c)ss$/, loader: ['style-loader', 'css-loader', 'sass-loader'] },
{ test: /\.woff2?$/, loader: 'file-loader' },
{ test: /\.(jpg|png|gif)$/, loader: 'file-loader' }
]
},
devServer: {
contentBase: 'src',
hot: true,
open: true,
port: 8000,
watchContentBase: true,
historyApiFallback: true,
proxy: {
'/api': 'http://localhost:4000'
}
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: 'src/index.html',
filename: 'index.html',
inject: 'body'
})
]
}
And here is my package.json:
{
"name": "results",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build": "webpack -p",
"serve:backend": "python manage.py runserver 4000",
"serve:frontend": "webpack-dev-server",
"seed": "python manage.py loaddata results/fixtures.json"
},
"dependencies": {
"#babel/core": "^7.5.5",
"#babel/plugin-transform-runtime": "^7.6.0",
"#babel/preset-env": "^7.6.0",
"#babel/preset-react": "^7.0.0",
"#babel/runtime": "^7.6.0",
"#fortawesome/fontawesome-free": "^5.10.2",
"axios": "^0.19.0",
"babel-loader": "^8.0.6",
"bulma": "^0.7.5",
"copy-webpack-plugin": "^5.0.4",
"css-loader": "^3.2.0",
"file-loader": "^4.2.0",
"html-webpack-plugin": "^3.2.0",
"jsonwebtoken": "^8.5.1",
"moment": "^2.24.0",
"moment-duration-format": "^2.3.2",
"node-sass": "^4.12.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-image": "^2.2.0",
"react-router-dom": "^5.0.1",
"react-select": "^3.0.4",
"react-select-async-paginate": "^0.3.13",
"react-toastify": "^5.4.0",
"sass-loader": "^7.3.1",
"style-loader": "^1.0.0",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.7"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^6.3.0",
"eslint-plugin-react": "^7.14.3",
"webpack-dev-server": "^3.8.0"
},
"engines": {
"node": "12.11.1",
"python": "3.7.5"
}
}
Settings.py
"""
Django settings for project project.
Generated by 'django-admin startproject' using Django 2.2.5.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# import dj_database_url
from dotenv import load_dotenv
import django_heroku
load_dotenv()
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['0.0.0.0', 'localhost', 'pairshead-results.herokuapp.com']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'rest_framework',
'results',
'django_filters',
'computed_property',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = [
'http://localhost:3030',
]
CORS_ORIGIN_REGEX_WHITELIST = [
'http://localhost:3030',
]
ROOT_URLCONF = 'project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-gb'
TIME_ZONE = 'Europe/London'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 25,
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
'PAGE_SIZE_QUERY_PARAM': 'page_size',
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication'
],
}
django_heroku.settings(locals())
# DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
urls.py (from projects folder)
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('django-admin/', admin.site.urls),
path('auth/', include('rest_framework.urls')),
path('api/', include('results.urls')),
path('api/', include('jwt_auth.urls')),
path('', include('frontend.urls')),
]
wsgi.py
"""
WSGI config for project project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
application = get_wsgi_application()
urls.py
from django.urls import path
from .views import clubs
from .views import events
from .views import bands
from .views import crews
from .views import competitors
from .views import times
from .views import results
from .views import masters_adjustments
from .views import original_event_category
urlpatterns = [
path('clubs/', clubs.ClubListView.as_view()),
path('club-data-import/', clubs.ClubDataImport.as_view()),
path('events/', events.EventListView.as_view()),
path('event-data-import/', events.EventDataImport.as_view()),
path('band-data-import/', bands.BandDataImport.as_view()),
path('bands/', bands.BandListView.as_view()),
path('crews/', crews.CrewListView.as_view(), name='crews-list'),
path('crews/<int:pk>', crews.CrewDetailView.as_view(), name='crews-detail'),
path('', crews.CrewListView.as_view()),
path('results/', results.ResultsListView.as_view()),
path('results-export/', results.ResultDataExport.as_view()),
path('crew-update-rankings/', crews.CrewUpdateRankings.as_view()),
path('crew-data-import/', crews.CrewDataImport.as_view()),
path('crew-data-export/', crews.CrewDataExport.as_view()),
path('competitor-data-export/', competitors.CompetitorDataExport.as_view()),
path('competitor-data-import/', competitors.CompetitorDataImport.as_view()),
path('race-times/', times.RaceTimeListView.as_view()),
path('race-times/<int:pk>', times.RaceTimeDetailView.as_view()),
path('crew-race-times/', times.CrewRaceTimesImport.as_view()),
path('masters-adjustments-import/', masters_adjustments.MastersAdjustmentsImport.as_view()),
path('original-event-import/', original_event_category.OriginalEventCategoryImport.as_view()),
]
I have a views folder with 9 view files:
init.py
from .bands import *
from .clubs import *
from .competitors import *
from .crews import *
from .events import *
from .times import *
from .results import *
from .masters_adjustments import *
procfile
web: python manage.py runserver 0.0.0.0:$PORT --noreload
Very grateful for any help anyone can offer. After reading a few similar questions, I tried setting {output: publicPath: '/'} and {historyApiFallback: true} in webpack.config.js but didn't seem to make any difference.
Your webpack and package.json configurations are absolutely fine. Your particular MIME type ("text/html") problem is in your Django configuration.
The views.py in your React frontend needs a content_type argument in the HttpResponse.
Heroku needs to know where your Webpack build files are.
You've configured Webpack to compile a production build of your React app, named this 'bundle.js', and told Webpack to put it in a folder called 'frontend/dist' along with a production build of your index.html. In Django parlance, these are your "static" files. (If you were using create-react-app instead of Webpack, this is the stuff in the 'build' folder.) In your settings.py, you need to tell heroku where to find these 'static' files. (explained below). But first, fix your frontend/views.py.
Your Home(View) is telling Heroku (or any server) to respond by sending index.html. Your Webpack 'HTMLWebpackPlugin' has injected a script into index.html which asks your Assets(View) to: look for bundle.js (and any other files stored in the same folder on the server), open it as 'rb', (which stands for 'read binary'), and return it to the user as an HttpResponse.
Your "refused to execute script ... MIME type ('text/html')" problem stems from Django's default content_type setting for an HttpResponse, which is text/html. https://docs.djangoproject.com/en/3.1/ref/request-response/#id3
Fix this by including a content_type='application/javascript' argument in the return statement of Assets(View) like so:
class Assets(View):
def get(self, _request, filename):
path = os.path.join(os.path.dirname(__file__), 'dist', filename)
if os.path.isfile(path):
with open(path, 'rb') as file:
return HttpResponse(file.read(), content_type='application/javascript')
else:
return HttpResponseNotFound()
With that sorted, there are several changes you need to make to your settings.py file help Heroku's Django configuration serve those files correctly.
As an aside, Heroku's Django deployment process recommends installing a middleware package ("Whitenoise") to compress and manage your static files, and a wsgi interface ("Gunicorn") to help Heroku communicate with Django. Your lack of these is not causing your issue, but they are part of Heroku's current recommended configuration so I am including them below.
First, in your settings.py your need to include the address of your heroku app in your allowed hosts, as well as your port and localhost like so:
ALLOWED_HOSTS = ['your-app-name.herokuapp.com/', '127.0.0.1', 'localhost']
Then you need to add the whitenoise middleware (don't forget to pip install it.) Make sure you list it second, directly after the django's security middleware:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
...
Then you need to add the path to where Webpack is storing your assets to the DIRS, in your case frontend/dist:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'frontend/dist')],
'APP_DIRS': True,
...
And finally and most importantly, you need to configure where you are storing your static files. In your case:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE =
"whitenoise.storage.CompressedManifestStaticFilesStorage"
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'frontend/dist')
]
The reason there is both a setting for STATIC_ROOT and for STATICFILES_DIRS is that STATIC_ROOT is where all the static files will be collected when Heroku automatically calls the command: manage.py collectstatic during deployment.
STATICFILES_DIRS is used to include additional directories collectstatic needs to look for. Make sure you reference the path to the folder where Webpack is storing your build files correctly! For your particular directory setup, that should be 'frontend/dist'
Don't forget to change your DEBUG settings to False for deployment.
Finally, you need to pip install gunicorn and change your Procfile to look like this:
release: python manage.py migrate
web: gunicorn project.wsgi --preload --log-file -
You should really check out the Heroku link: https://blog.heroku.com/from-project-to-productionized-python because it walks you through Heroku and Heroku's environment setup. It also states Heroku expects a requirements.txt file specifying the versions of the python packages you have installed and a runtime.txt file specifying your version of Django. But but since you're using Pipenv instead of venv, I think your Pipfile makes those unnecessary.
Here is a outline following Heroku's from-product-to-productionized instructions for a Django deployment to Heroku, with the necessary steps for including a React + Webpack frontend inserted in the proper order:
--------Pre-deployment-------------
Signup for Heroku
Install the Heroku CLI
Set up a virtual enviroment with either pipenv shell or or venv https://docs.python.org/3/tutorial/venv.html
Update .gitignore to include:
/your-venv-directory
__pycache__
db.sqlite3
your-app-name/static/
frontend/dist
.env
[Heroku recommends you use your settings.py for local development and a create a second file (heroku.py) with the package django-environ to import your env settings for deployment. It's much easier their way, but you are managing fine with your env config so I'll skip that here. Check modularize-your-settings and setting-up-code-heroku-py for the recommended setup]
Install django-heroku and add
import django_heroku
to the top of the settings.py file and
django_heroku.settings(locals())
to the bottom of the settings.py file
Install whitenoise and add it as middleware to settings.py
Install psycopg2 http://initd.org/psycopg/docs/
This is notoriously difficult to install, but installing the raw psycopg2-binary as you did here seems to work in a pinch.
Create a requirements.txt file and run pip freeze > requirements.txt and create a runtime.txt file and specify your current python build version so things don't break down the road. As you're using pipenv which generates a Pipfile.lock I'm not sure this is strictly necessary, as pipenv supercedes but you should freeze your current package and python build versions into your Pipfile, so things don't break down the road.
Install the web servers gateway interface (WSGI) process that actually serves your heroku application: gunicorn
https://devcenter.heroku.com/articles/python-gunicorn
https://docs.gunicorn.org/en/latest/settings.html
Create a file named Procfile (MAKE SURE THE 'P' IS CAPITALIZED!!!) and add:
release: python manage.py migrate
web: gunicorn gettingstarted.wsgi --preload --log-file -
Make sure you have a build script in your package.json
"scripts": {
"build": "webpack -p" }
Run this build script (yarn build) and confirm your app is working locally.
--------Deployment------------------
From your terminal run:
heroku login
heroku create --region=eu your-app-name
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/python (Make sure you add the buildpacks in that order!)
heroku config:set ALLOWED_HOSTS=your-app-name.herokuapp.com
heroku config:set DJANGO_SETTINGS_MODULE=project.settings (if you added a deployment settings file to use django-environ as the modularize-your-settings link suggested above, then use heroku config:set DJANGO_SETTINGS_MODULE=project.settings.herokuDotPyOrWhateverYouNamedIt)
heroku config:set SECRET_KEY=INSERTASECURESECRETKEYPASSWORD
heroku config:set WEB_CONCURRENCY=1
heroku addons:create heroku-postgresql:hobby-dev
Make sure you are on your master branch and all changes have been committed to git and run
git push heroku master
or if you are working from another branch, commit to git and run
git push heroku yourbranch:master replacing 'yourbranch' with the name of your branch.
heroku run python manage.py migrate
If you have a fixtures.json file containing your database seeds run
heroku run python manage.py loaddata your-django-project-name/fixtures.json
heroku ps:scale web=1
heroku open
If there are any errors, run
heroku logs --tail
to investigate

Google App Engine standard - composer update --lock | Allowed memory size exhausted | Error 255

we have a PHP - Symfony project that we would like to run on Google Cloud App Engine Standard but we cannot deploy the app using gcloud app deploy app.yml because the build fails.
app.yml
runtime: php
service: "papi-dev"
instance_class: F2
env_variables:
APP_ENV: prod
APP_DEBUG: true
DATABASE_URL: mysql://p...
runtime_config:
document_root: ./public
front_controller_file: index.php
enable_stackdriver_integration: true
handlers:
# Declare the build and bundles directory as static assets to be served by the
# App Engine CDN.
- url: /build
static_dir: public/build
composer.json
{
"type": "project",
"license": "proprietary",
"require": {
"php": "7.2.*",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"api-platform/api-pack": "^1.1",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"friendsofsymfony/elastica-bundle": "^5.0",
"friendsofsymfony/oauth-server-bundle": "^1.6",
"friendsofsymfony/user-bundle": "^2.1",
"google/apiclient": "^2.0",
"google/cloud-error-reporting": "^0.12.1",
"google/cloud-logging": "^1.14",
"guzzlehttp/guzzle": "~6.0",
"jms/serializer-bundle": "^2.4",
"lexik/jwt-authentication-bundle": "^2.5",
"nelmio/cors-bundle": "^1.5",
"pear/net_dns2": "^1.4",
"productsupcom/jenkins-php-api": "^0.1.4",
"sendgrid/sendgrid": "^7.2",
"sensio/framework-extra-bundle": "^5.2",
"symfony/console": "*",
"symfony/dotenv": "*",
"symfony/expression-language": "*",
"symfony/flex": "^1.1",
"symfony/framework-bundle": "*",
"symfony/lock": "4.1.*",
"symfony/maker-bundle": "^1.7",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/proxy-manager-bridge": "*",
"symfony/templating": "4.1.*",
"symfony/translation": "4.2.*",
"symfony/yaml": "*",
"webonyx/graphql-php": "^0.12.6",
"wisembly/elephant.io": "^3.3"
},
"require-dev": {
"symfony/phpunit-bridge": "4.1.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.2.*"
}
}
}
builder log
Step #1 - "builder": INFO composer_update_lock composer update --lock
Step #1 - "builder": INFO `composer_update_lock` stdout:
Step #1 - "builder":
Step #1 - "builder": Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 9437184 bytes) in phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php on line 565
Step #1 - "builder":
Step #1 - "builder": Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
Step #1 - "builder": INFO `composer_update_lock` had stderr output:
Step #1 - "builder": Do not run Composer as root/super user! See https://getcomposer.org/root for details
Step #1 - "builder": Loading composer repositories with package information
Step #1 - "builder": Updating dependencies (including require-dev)
Step #1 - "builder": Package operations: 128 installs, 0 updates, 0 removals
Step #1 - "builder": - Installing symfony/flex (v1.1.8): Downloading (connecting...)Downloading (0%) Downloading (20%)Downloading (25%)Downloading (45%)Downloading (60%)Downloading (65%)Downloading (75%)Downloading (80%)Downloading (90%)Downloading (95%)Downloading (100%)
Step #1 - "builder":
Step #1 - "builder": ERROR error: `composer_update_lock` returned code: 255
The deploy command used to work until we've added more packages to composer.json. Best guess I have so far is that the build stopped working because of this github commit to the cloud builder image which executes composer update --lock upon every deploy/build execution.
Solved by Google - composer install is called instead of composer update.

Angular Unit tests failing, not able to inject servies

this is my karma.conf.js
`use strict`;
var path = require('path');
var conf = require('./gulp/conf');
var _ = require('lodash');
var wiredep = require('wiredep');
var pathSrcHtml = [
path.join(conf.paths.src, '/**/*.html')
];
function listFiles() {
var wiredepOptions = wiredep({
directory: 'src/bower_components',
exclude: [],
dependencies: true,
devDependencies: true
});
return wiredep(wiredepOptions).js
.concat([
path.join(conf.paths.src, '/app/**/*.module.js'),
path.join(conf.paths.src, '/app/**/*.js'),
path.join(conf.paths.src, '/app/*.spec.js')
])
.concat(pathSrcHtml);
}
module.exports = function(config) {
var files=['https://maps.googleapis.com/maps/api/js?sensor=false'].concat(listFiles());
var configuration = {
files: files,
singleRun: true,
autoWatch: false,
ngHtml2JsPreprocessor: {
stripPrefix: conf.paths.src ,
moduleName: 'truelocal'
},
logLevel: 'WARN',
frameworks: ['jasmine', 'angular-filesort'],
angularFilesort: {
whitelist: [path.join(conf.paths.src, '/**/!(*.html|*.spec|*.mock).js')]
},
browsers : ['PhantomJS'],
plugins : [
'karma-phantomjs-launcher',
'karma-angular-filesort',
'karma-coverage',
'karma-jasmine',
'karma-ng-html2js-preprocessor'
],
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
captureConsole: true,
reporters: ['progress']
};
// This is the default preprocessors configuration for a usage with Karma cli
// The coverage preprocessor in added in gulp/unit-test.js only for single tests
// It was not possible to do it there because karma doesn't let us now if we are
// running a single test or not
configuration.preprocessors = {};
pathSrcHtml.forEach(function(path) {
configuration.preprocessors[path] = ['ng-html2js'];
});
// This block is needed to execute Chrome on Travis
// If you ever plan to use Chrome and Travis, you can keep it
// If not, you can safely remove it
// https://github.com/karma-runner/karma/issues/1144#issuecomment-53633076
if(configuration.browsers[0] === 'Chrome' && process.env.TRAVIS) {
configuration.customLaunchers = {
'chrome-travis-ci': {
base: 'Chrome',
flags: ['--no-sandbox']
}
};
configuration.browsers = ['chrome-travis-ci'];
}
config.set(configuration);
};
//Bower.json
{
"name": "truelocal",
"version": "0.0.0",
"dependencies": {
"angular": "~1.4.10",
"angular-animate": "~1.4.10",
"angular-aria": "~1.4.10",
"angular-bootstrap": "~0.13.4",
"angular-cookies": "~1.4.10",
"angular-local-storage": "~0.2.3",
"angular-messages": "~1.4.10",
"angular-resource": "~1.4.10",
"angular-sanitize": "~1.4.10",
"angular-toastr": "~1.5.0",
"angular-touch": "~1.4.10",
"animate.css": "~3.4.0",
"bootstrap": "~3.3.5",
"jquery": "~1.11.3",
"malarkey": "yuanqing/malarkey#~1.3.1",
"moment": "~2.10.6",
"moment-parseformat": "~1.1.3",
"ng-file-upload-shim": "~9.1.2",
"jQuery.dotdotdot": "~1.7.4",
"lodash": "3.10.1",
"angular-ui-router": "~0.2.18",
"markerclustererplus": "~2.1.4",
"ng-fastclick": "~1.0.2",
"angular-swipe": "~0.1.0",
"angular-bindonce": "~0.3.3",
"angular-loading-bar": "~0.9.0",
"jquery-placeholder": "~2.3.1",
"angular-shims-placeholder": "^0.4.7"
},
"devDependencies": {
"angular-mocks": "~1.4.10"
},
"overrides": {
"bootstrap": {
"main": [
"dist/css/bootstrap.css",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff",
"dist/fonts/glyphicons-halflings-regular.woff2"
]
}
},
"resolutions": {
"jquery": "~1.11.3",
"angular": "^1.5.7"
}
}
This is an existing project with more than 200 Unit tests written, the code might need a bit of update but i'm not able to execute any unit test with dependent services.
I'm guessing the angular-mocks is causing an issue, if i move it up in the dependencies i dont get the module missing error. but i still dont get the other dependencies in the unit tests.
The Karma.conf.js was missing one file from the project. once all the files are fed to the test conf. tests worked like a Charm!

How to debug a JSPM-SystemJS-AngularJS project in Webstorm 11

Debugging my project in Webstorm 11 I get an error.
If I run the project instead, it runs fine.
I am following the JSPM - Getting Started. Debugging the Javascript module is fine. The error occurs once I try to integrate Angular into my project.
What do I do wrong?
Error when debugging:
Uncaught (in promise) Error: ReferenceError: module is not defined
at eval (http://localhost:63342/JSPM-Angular-playground/jspm_packages/npm/babel-core#5.8.35.js:1:1)
Evaluating http://localhost:63342/JSPM-Angular-playground/jspm_packages/npm/babel-core#5.8.35.js
Error loading http://localhost:63342/JSPM-Angular-playground/jspm_packages/npm/babel-core#5.8.35.js
Error loading http://localhost:63342/JSPM-Angular-playground/app/app.js
t
g
(anonymous function)
Project setup:
package.json
{
"jspm": {
"dependencies": {
"angular": "github:angular/bower-angular#^1.5.0"
},
"devDependencies": {
"babel": "npm:babel-core#^5.8.24",
"babel-runtime": "npm:babel-runtime#^5.8.24",
"core-js": "npm:core-js#^1.1.4"
}
},
"devDependencies": {
"jspm": "^0.16.31"
}
}
config.js
System.config({
baseURL: "/JSPM-Angular-playground",
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"runtime",
"optimisation.modules.system"
]
},
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
"angular": "github:angular/bower-angular#1.5.0",
"babel": "npm:babel-core#5.8.35",
"babel-runtime": "npm:babel-runtime#5.8.35",
"core-js": "npm:core-js#1.2.6",
"github:jspm/nodelibs-assert#0.1.0": {
"assert": "npm:assert#1.3.0"
},
"github:jspm/nodelibs-path#0.1.0": {
"path-browserify": "npm:path-browserify#0.0.0"
},
"github:jspm/nodelibs-process#0.1.2": {
"process": "npm:process#0.11.2"
},
"github:jspm/nodelibs-util#0.1.0": {
"util": "npm:util#0.10.3"
},
"npm:assert#1.3.0": {
"util": "npm:util#0.10.3"
},
"npm:babel-runtime#5.8.35": {
"process": "github:jspm/nodelibs-process#0.1.2"
},
"npm:core-js#1.2.6": {
"fs": "github:jspm/nodelibs-fs#0.1.2",
"path": "github:jspm/nodelibs-path#0.1.0",
"process": "github:jspm/nodelibs-process#0.1.2",
"systemjs-json": "github:systemjs/plugin-json#0.1.0"
},
"npm:inherits#2.0.1": {
"util": "github:jspm/nodelibs-util#0.1.0"
},
"npm:path-browserify#0.0.0": {
"process": "github:jspm/nodelibs-process#0.1.2"
},
"npm:process#0.11.2": {
"assert": "github:jspm/nodelibs-assert#0.1.0"
},
"npm:util#0.10.3": {
"inherits": "npm:inherits#2.0.1",
"process": "github:jspm/nodelibs-process#0.1.2"
}
}
});

I can't install Doctrine Migrations via Composer

I've searched everywhere to fix my problem but i think my problem is a new one and there is not solution.
I've added doctrine/migrations to my composer file, and when i type
composer update
this problem shows up:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing doctrine/migrations (dev-master a4f14d3)
Failed to download doctrine/migrations from source: Could not delete /var/www/vendor/doctrine/migrations/.git/objects/pack/tmp_idx_1vS7c6:
Now trying to download from dist
- Installing doctrine/migrations (dev-master a4f14d3)
[RuntimeException]
Could not delete /var/www/vendor/doctrine/migrations/.git/objects/pack/tmp_idx_1vS7c6:
My composer file:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.2",
"doctrine/migrations": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability" : "dev",
"prefer-stable" : true,
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
Any ideas what is wrong?
After chmoding the /var/www/vendor i get this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing doctrine/migrations (dev-master a4f14d3)
Cloning a4f14d3a3d397104e557ec65d1a4e43bb86e4ddf
Failed to download doctrine/migrations from source: Could not delete /var/www/vendor/doctrine/migrations/.git/objects/pack/tmp_pack_V57bD0:
Now trying to download from dist
- Installing doctrine/migrations (dev-master a4f14d3)
[RuntimeException]
Could not delete /var/www/vendor/doctrine/migrations/.git/objects/pack/tmp_pack_V57bD0:

Resources