I am setting up a Laravel solution where I want to use a SQLite database configured as in memory database.
I have the following configuration for this:
.env:
DB_CONNECTION_DATA=sqlite
DB_DATABASE_DATA=:memory:
database.php:
...
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE_DATA'),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
Migration works fine with this configuration but seeding fails with error message:
SQLSTATE[HY000]: General error: 1 no such table: permissions (SQL: select * from "permissions")
I have googled around to find a solution for this and found this package:
laravel-sqlite-named-memory-connection
Here it is described that:
It connects to SQLite's in-memory database as well as :memory:. :memory: creates a new database for each connection, whereas :named-memory:<name> returns the same connection  if <name> is same.
So I assume that this is the explanation why seeding does not work because it is run in another connection than the migrations so the database does not exist for the seeding connection.
I could then use this package to solve this but the challenge is that it seem to be set up for Laravel 7, not 8 which I use and has not been updated for the last 3 years.
Anyone know if there are similar, more up to date, packages available or other ways to configure this?
PS: In googling I have found solutions in context of test use but I want to use this in production.
Tried:
php artisan db:seed PermissionsSeeder
Got error message:
SQLSTATE[HY000]: General error: 1 no such table: permissions (SQL: select * from "permissions")
Expected:
Successful seeding.
Also tried:
composer require crhg/laravel-sqlite-named-memory-connection
Got error message:
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^1.1 for crhg/laravel-sqlite-named-memory-connection
./composer.json has been updated
Running composer update crhg/laravel-sqlite-named-memory-connection
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- crhg/laravel-sqlite-named-memory-connection[v1.1.0, ..., v1.1.2] require illuminate/support ^5.5 || ^6.0 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev] but these were not loaded, likely because it conflicts with another require.
- crhg/laravel-sqlite-named-memory-connection v1.1.3 requires illuminate/support ^5.5 || ^6.0 || ^7.0 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires crhg/laravel-sqlite-named-memory-connection ^1.1 -> satisfiable by crhg/laravel-sqlite-named-memory-connection[v1.1.0, v1.1.1, v1.1.2, v1.1.3].
You can also try re-running composer require with an explicit version constraint, e.g. "composer require crhg/laravel-sqlite-named-memory-connection:*" to figure out if any version is installable, or "composer require crhg/laravel-sqlite-named-memory-connection:^2.1" if you know which you need.
Expected:
Successful package installation.
Related
In my composer.json, I added doctrine-fixtures-bundle in require-dev as recommended in the documentation
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3",
...
},
I created a new symfony benchmark environment, but I cannot access the fixtures :
$ APP_ENV=benchmark php bin/console doctrine:fixtures:load
You may be looking for a command provided by the "DoctrineFixturesBundle" which is currently not installed. Try running "composer require doctrine/doctrine-fixtures-bundle --dev"
Fixtures is available in dev. How to make it also accessible in benchmark environment ?
I don't think adding fixtures in require to composer.json is a good idea : it's not safe.
You should not define this library as a dev dependency then. Move it from the require-dev to the require section and reinstall vendors with Composer.
It's "not safe" as in you could potentially load the fixtures on production and erase your database. If you are afraid you could do so, you can load this bundle for the benchmark environment only, eg.:
// config/bundles.php
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'benchmark' => true],
I have a working symfony project. I have it on a private bitbucked repository and locally the website works without an issue.
Today I tried to deploy the project onto an external server linuxpl.com.
Steps taken include:
Istalling composer
Adding the mysql database
Running git clone to get the data into a proper location
Running composer install on the folder to install everything and connect to the db
Cleared the cache
Set the project root as ....domain/project_name/web
However after completing all these steps, when running the website with regular server:run I'm getting this odd error:
Parse error: syntax error, unexpected '.' in /home/spirifer/domains/surowcewobiektywie.pl/konkurs/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1571
Not sure if this is of any importance but the mentioned code partion looks like this in my local files:
// Some objects throw exceptions when they have __call, and the method we try
// to call is not supported. If ignoreStrictCheck is true, we should return null.
try {
$ret = $object->$method(...$arguments);
} catch (BadMethodCallException $e) {
if ($call && ($ignoreStrictCheck || !$env->isStrictVariables())) {
return;
}
throw $e;
}
The local version does not differ from the one on the server.
My local machine has PHP 7.0.9 and the remove server has PHP 7.0.14
How could I fix this issue?
PHP 5.6 adds Variadic functions, with "...". However, Twig v1.x only required the use of PHP 5.2.7 or above.
If you didn't explicitly update to Twig 2.0, it's very possible you have used the 'death star' version constraint in the composer file - '*'. which allows uncontrolled version updates to the latest version. If this is the case, you will need to either update your version of PHP, or at least require just a previous version of Twig/twig, "^1.32" would be the latest in the version 1 series of Twig.
I need to get a few ecommerce components from bundles. So I found Sylius E-Commerce bundle. And I want to install the Shipping Bundle.
http://docs.sylius.org/en/latest/bundles/SyliusShippingBundle/index.html
However at the last part, when I need to update my schema I get this error:
Fatal error: Class 'Sylius\Component\Translation\Model\AbstractTranslatable' not found in C:\wamp\www\karpedealb2c\vendor\sylius\shipping\Model\ShippingMethod.php on line 24
So I go to the Sylius vendor and I can see that the class AbstractTranslatable doesnt exist.. I did some research and I found that these models are a part of a SyliusTranslationBundle that doesnt even exist anymore...
Do these bundles even work? Its not the first time I cant install Sylius Bundles.
P.S Are there any other good bundles that offer different e-commerce models and etc?
UPDATE
If I try to add them seperately:
"sylius/translation-bundle": "^0.15.0",
"sylius/shipping-bundle": "^0.15.0",
"sylius/resource-bundle": "0.16.*
I get these errors hen updating composer:
Problem 1
- The requested package sylius/resource-bundle could not be found in any version, there may be a typo in the package name.
Problem 2
- Installation request for sylius/translation-bundle ^0.15.0 -> satisfiable by sylius/translation-bundle[v0.15.0].
- sylius/translation-bundle v0.15.0 requires sylius/resource-bundle 0.15.*#dev -> no matching package found.
Problem 3
- Installation request for sylius/shipping-bundle ^0.15.0 -> satisfiable by sylius/shipping-bundle[v0.15.0].
- sylius/shipping-bundle v0.15.0 requires sylius/resource-bundle 0.15.*#dev -> no matching package found.
I have started using Berkshelf, it seems to make sense, but I can't wrap my head around how it should work.
First I created a cookbook using berks cookbook mycookbook. Then I added a dependency to only find that it cannot find mycookbook when I run berks install
So it seems that mycookbook (which is version 0.1.0) depends on default on mycookbook version 0.1.0. Why should mycookbook depend on mycookbook?
Unable to satisfy constraints on package java due to solution constraint (mycookbook = 0.1.0). Solution constraints that may result in a constraint on java: [(mycookbook = 0.1.0) -> (java ~> 1.31.1)]
Demand that cannot be met: (mycookbook = 0.1.0)
Artifacts for which there are conflicting dependencies: java = 1.31.0 -> []Unable to find a solution for demands: mycookbook (0.1.0)
It seems you get this message if you create a cookbook that already exists? I'm not sure. But after renaming it the message is gone.
Can anyone tell me why the code below throws the following error? :
Error: A method named '/players/insert' is already defined
I'm new to Meteor and coffeescript so I may be overlooking something simple.
Here's my port of the leaderboard example to coffeescript:
###
Set up a collection to contain player information. On the server,
it is backed by a MongoDB collection named "players."
###
Players = new Meteor.Collection("players")
if Meteor.is_client
Template.leaderboard.players = ->
Players.find({}, {sort: {score: -1, name: 1}})
Template.leaderboard.selected_name = ->
player = Players.findOne(Session.get "selected_player")
player and player.name
Template.player.selected = -> if Session.equals("selected_player", this._id) then "selected" else ''
Template.leaderboard.events = {
'click input.inc': ->
Players.update(Session.get("selected_player"), {$inc: {score: 5}})
}
Template.player.events = {
'click': ->
Session.set("selected_player", this._id)
}
# On server startup, create some players if the database is empty.
if Meteor.is_server
Meteor.startup ->
if Players.find().count() is 0
names = [
"Ada Lovelace"
"Grace Hopper"
"Marie Curie"
"Carl Friedrich Gauss"
"Nikola Tesla"
"Claude Shannon"
]
Players.insert({name: name, score: Math.floor(Math.random()*10)*5}) for name in names
The full stack trace is as follows:
[[[[[ ~/dev/meteor/leaderboard ]]]]]
Running on: http://localhost:3000/
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: A method named '/players/insert' is already defined
at app/packages/livedata/livedata_server.js:744:15
at Function.<anonymous> (app/packages/underscore/underscore.js:84:24)
at [object Object].methods (app/packages/livedata/livedata_server.js:742:7)
at new <anonymous> (app/packages/mongo-livedata/collection.js:111:13)
at app/leaderboard.js:4:11
at /Users/alex/dev/meteor/leaderboard/.meteor/local/build/server/server.js:109:21
at Array.forEach (native)
at Function.<anonymous> (/Users/alex/dev/meteor/leaderboard/.meteor/local/build/server/underscore.js:76:11)
at /Users/alex/dev/meteor/leaderboard/.meteor/local/build/server/server.js:95:7
Exited with code: 1
I'm running Meteor version 0.4.0 (8f4045c1b9)
Thanks in advance for assistance!
You would also get this error, regardless of using coffeescript or plain javascript, if you duplicated your files. For example, copying your sources files to a subdirectory named Backup would produce this error, because Meteor merges files from subdirectories.
This appears to be a configuration issue with coffeelint (installed globally with npm).
I originally installed coffeelint to check that my coffeescript code was correct and had no errors.
I installed coffeelint as per the instructions with:
sudo npm install -g coffeelint
coffeelint worked fine when run stand-alone against .coffee files.
However, when running any Meteor project with coffeescript package added I got the above error.
On a whim, I thought the error might be due to conflict with my exisiting node install.
I decided to uninstall coffeelint first with:
sudo npm uninstall -g coffeelint
and then deleted the previously meteor-generated leaderboard.js file.
After re-starting meteor the coffeescript example above worked as expected without errors.
try moving (ie copying and deleting the original )
Players = new Meteor.Collection("players")
one time below if Meteor.is_client
and another time below if Meteor.is_server
I don't know exactly why, as I'm new to Meteor too, but that worked for me, I assume that the server side needs it's own reference,as well as the client,
although declaring outside the scope should do the same (maybe a bug, remember they're still at 0.5.0 preview , which makes me think you might wanna upgrade and try some new smart packages that are with the new version, it looks like you're using 0.4), but when the files in my server wouldn't recognize anything I defined the root directory of meteor (which pushes these files to both client and server), I defined the server's own reference, and I got the same error, and until I moved the 'public' declaration of the reference to give the server and the client each their own copy, nothing worked.
Hopefully that helps...